LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   script not running correctly off cron (https://www.linuxquestions.org/questions/linux-software-2/script-not-running-correctly-off-cron-103410/)

wedgeworth 10-13-2003 09:40 AM

script not running correctly off cron
 
i have a expect script that is using ssh to retrieve the file size from a remote source and comparing it with a local file size. this works fine. i then compare the two and send an e-mail to myself with the result...(yes it worked or no they're different). i run the script directly from the command line i get the report e-mailed to me. i set the cron to call the script and nothing happends. any help would be great. here is the code from the script surrounding the e-mail:

.
.
.
.
#check difference
if {$SIZE != $SIZE2} {
send_user "not equal\n"
exec /bin/mail -s *****ATTENTION***** me@myemail.com << "From: file_compare
To: me@myemail.com
Subject: WARNING- NOT EQUAL
backup.$HOSTNAME.$DATE.tar files not equal\n"
} else {
send_user "equal\n"
exec /bin/mail -s $DATE.$HOSTNAME.report me@myemail.com << "From: file_compare
To: me@myemail.com
Subject: Files are Equal
backup.$HOSTNAME.$DATE.tar at size $SIZE\n"
}

wedgeworth 10-13-2003 10:25 AM

ok i've learned that the problem isn't with the above code (the exec command works fine). problem is with interact control that is in the script above before the mail command. (i'm using interact therefore the script works fine from the command line ). the problem is i have the interact command in the scirpt bookended by log-file commands to retrieve the filesize that is being outputted by the ssh command. if anyone knows how to have the interact command that retrieves the output from ssh and still is able to have the exec work correctly afterwards (stop the scirpt from "interacting") then i would appreciate any help:

#get SIZE
spawn du -sk backup.$HOSTNAME.$DATE.tar
#set SIZE [exec du -sk backup.$HOSTNAME.$DATE.tar]
log_file -noappend file
interact
log_file
set SIZE [read $file1 7]
#set SIZE 10

#get SIZE2
spawn ssh backup@www.bob.com du -sk /Volumes/extdrive1/serverBackups/backup.$HOSTNAME.$DATE.tar|cut -f1|tr -d A-Z " "
expect -re "backup@www.bob.com's password:"
send "******\r"
log_file -noappend typescript
interact -re
log_file
set junk [read $file 1]
set SIZE2 [read $file 100000]

#printout
send_user "SIZE is $SIZE\n"
send_user "SIZE2 is $SIZE2\n"

#check difference
if {$SIZE != $SIZE2} {
.
.
.
.


code from here on is seen above. if you take the interact commands out then the "exec mail....." commands work fine. the interact is messing things up. i need to kil the spawned process and don't know how to yet.

wedgeworth 10-13-2003 11:38 AM

control returns to the script after spawn is terminated. i don't know how to do this though. any help....? putting in "close" after the interact and log_file command does not work.

wedgeworth 10-14-2003 08:30 AM

i've also tried putting in "return" statements after the both log_file command.....this is suppose to return control back to the scirpt (while exit returns control to whatever called the script), however it does not seem to be working correclty. they almost seem to be acting as exit statements. if you know how to get the interact to return control back to the script itself (or if you know how to use expect_out....maybe that would work????) i would appreciate.


All times are GMT -5. The time now is 02:40 AM.