Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

expect help

Status
Not open for further replies.

alan147

Technical User
Nov 15, 2002
128
GB
Good afternoon

I need a bit of help with an expect script. I have written a script that gets a list of files on an FTP server, it then downloads them. The actual FTP is controlled using an expect script ( shown below )

!/usr/bin/expect -f

set env(TERM) vt100

spawn /usr/bin/sftp -b {path to FTP batch file} username@ftpserver

expect -exact "username@ftpserver's password: "

sleep 20

send -- "\*******\r"

expect eof


The batch file contains a list of files to download.

The batch file looks like this:

cd /{file path}
get file1
get file2
get file3
cd /{path to remote subdirectory}
lcd /{path to local subdirectory}
get file4

The script works as I want when run from the command prompt, but as a cron job it's a different story. When I added this set env(TERM) vt100 it ran as cron job but would only download one file, if there was more than one file it didn't download them.

Any ideas?

Thanks

Alan
 
What error messages did you get? Did you redirect the output of the cron job to a log file? If not, it was probably sent to you in mail. Check your mail on that server.

 
Sadly there is nothing in the cron log or mail.

Alan
 
Which file did it get first / last?

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Also can you post the line from cron which calls the script

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
I think I might have cracked it, I append the batch file with

expect eof


and ran a test this morning which successfully downloaded 6 files.

Thanks

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top