Hi All,
I have an expect script called sftp to transfer using SFTP below :
[root@prod:/root]
# more sftp
#!/usr/local/bin/expect
# Initialisation
set authFile "/home/ap1030/transfer/.password"
# Check the authorisation file exists
if {![file exists $authFile]} { ;# Does file exist
send_user "$authFile does not exist; aborting\n"
exit 1
}
set fileFD [open $authFile r] ;# Open the auth file
gets $fileFD authLine ;# Read in 1 line to authLine
close $fileFD
# Transfer file(s)
spawn /opt/openssh/bin/sftp -b /home/ap1030/transfer/batchFile importve@
www.importve.com
expect "password:"
send "$authLine\n";
interact
When I run this script manually from command line, it was running fine. But when I put on crontab, it was NOT working. I believe this is related to "interact" command on the last line. It always get stuck after password. How can I overcome this problem? Pls help.
Below is my crontab entry and the log file. Pls help.
05 15 * * * /usr/local/bin/expect -f /home/ap1030/transfer/sftp > /tmp/sftp 2>1&
[importve@sihp8026:/home/ap1030/transfer]
$ more /tmp/sftp
spawn /opt/openssh/bin/sftp -b /home/ap1030/transfer/batchFile importve@
www.importve.com
Connecting to
www.importve.com...
importve@
www.importve.com's password:
Thanks and Best Regards,
Dewa