I have made the below expect script and I need to log the output of that script.
SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' `
if [ -n "${SOURCE_FILE}" ]
then
cp -p ${SOURCE_FILE} ${T_FILES}
/usr/bin/expect<<EOD
set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$password\r"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txt\r"
expect "sftp>"
send "bye\r"
expect EOD
EOD
else
echo "No Files to copy" >> ${LOGFILE}
fi
I need to log the output of expect command in ${LOGFILE}
. How can It be done?
I have tried adding the below things, it doesn't work. What could be done?
/usr/bin/expect<<EOD >> ${LOGFILE} 2>&1
set timeout 60
spawn sftp $ES_SFTP_USER@$ES_SFTP_HOST_NAME:$R_LOCATION
expect "*?assword:"
send "$password\r"
expect "sftp>"
send "put /opt/AppServer/ES_TEST/todays_report/*.txt\r"
expect "sftp>"
send "bye\r"
expect EOD
EOD