Spawn command not found

8,473

When you run a script as an argument to shell, like you are doing:

sh a.sh

the shebang will be ignored and the script a.sh will be interpreted by sh. As there is no such command as spawn in your system (spawn is expect specific command), shell is throwing the given error.

Given your shebang is #!/usr/bin/expect, it is not clear what you are trying to do as you have many (all except spawn) non expect specific commands in the script.

Share:
8,473

Related videos on Youtube

Vijay
Author by

Vijay

Updated on September 18, 2022

Comments

  • Vijay
    Vijay over 1 year

    I trying to use the spawn command to connect to remote server, execute some commands/script.

    Here is script:

    #!/usr/bin/expect
    for i in `srvctl status database -d PROD | awk -F " " '{print $(NF)}'`
    do
    echo "value of i is $i"
    spawn ssh "$i"
    echo "vijay"
    done
    

    Here is output

    bash-3.2$ sh a.sh
    value of i is prod1
    a.sh: line 8: spawn: command not found
    vijay
    value of i is prod2
    a.sh: line 8: spawn: command not found
    vijay
    

    I am using RHEL 5.11 .

     bash-3.2$ expect -v
     expect version 5.43.0
    

    Thanks in Advance.

    • Alessio
      Alessio almost 8 years
      public-key ssh authentication is a lot safer and a lot more reliable than a scripted login with expect.
  • Vijay
    Vijay almost 8 years
    After referring to few old posts, i have written those commands, If its wrong, then how I can run ssh to remote server and run some commands ?
  • heemayl
    heemayl almost 8 years
    @Vijay That goes as a new question i am afraid :)
  • Vijay
    Vijay almost 8 years
    Posted as new question.