Issue - Expect Script.

Hi Gurus,I am trying to automate SFTP using expect.I have written a script that logs into a few boxes(one after the other) and pulls a few files from them.The code:#!/bin/kshcat serverlist.conf|wc -l >> tmp #serverlist.conf contains the list of servers.tmp1=$tmpfor tmp1 in listdo while read inputline do SERVERNAME="$inputline"#!/usr/local/bin/expect -fspawn sftp -v boi@$SERVERNAMEexpect "password:"sleep 10send "boi\r"expect "sftp>"send "get errors.log\r"expect "sftp>"send "exit\r" done < winbad.conf tmp:=tmp-1doneexit 0When i run this,i get the error "spawn command not found". Can anyone help me in resolving this.ThanksHG

First get the code sorted out in a formatted manner.

And is expect installed correctly on your machine ?

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Hi Gurus,

Apologies for putting it in an unformatted way.
Am putting my query again.

I am trying to automate SFTP using expect.I have written a script that logs into a few boxes(one after the other) and pulls a few files from them.

The code:

 
#!/bin/ksh
cat serverlist.conf|wc -l >> tmp #serverlist.conf contains list of servers.
tmp1=$tmp
for tmp1 in list do 
while read inputline 
do 
SERVERNAME="$inputline"
 
#!/usr/local/bin/expect -f
spawn sftp -v boi@$SERVERNAME
expect "password:"
sleep 10
send "boi\r"
expect "sftp>"
send "get errors.log\r"
expect "sftp>"
send "exit\r" 
 
done < serverlist.conf 
tmp:=tmp-1
done
exit 0

When i run this,i get the error "spawn command not found".
Can anyone help me in resolving this.

Thanks
HG