SFTP in Crontab

Occasional Contributor

SFTP in Crontab

hello all....i had write a small script for SFTP some file from unix server to other Unix Server...the only possible way is using SFTP...i had use expect to automate the script...as well only expect is can be use...when i run the script manully it works fine...but when i had put it in crontab list to automatic scheduale for the script it failed...

my script as follow:

#!/usr/bin/env expect
set HOST xxxxx
set PORT 22
set USER xxxxx
set PASSWORD xxxx
set SOURCE_FILE my_source
set TARGET_DIR my_target
spawn /usr/bin/sftp -o Port=$PORT $USER@$HOST
expect "password:"
send "$PASSWORD\r"
expect "sftp>"
send "put $SOURCE_FILE* $TARGET_DIR\r"
expect "sftp>"
send "bye\r"

my crontab is :

30 14 * * * /sched


can you please support to know who i can automate my script in crontab...




Occasional Contributor

Re: SFTP in Crontab

i had solve the issue by change the Env in my script as well in my crontab