Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Log the output of Expect command

$
0
0

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

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>