LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-13-2003, 09:40 AM   #1
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Rep: Reputation: 30
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"
}

Last edited by wedgeworth; 10-13-2003 at 09:41 AM.
 
Old 10-13-2003, 10:25 AM   #2
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
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.

Last edited by wedgeworth; 10-13-2003 at 11:46 AM.
 
Old 10-13-2003, 11:38 AM   #3
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
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.

Last edited by wedgeworth; 10-13-2003 at 12:08 PM.
 
Old 10-14-2003, 08:30 AM   #4
wedgeworth
Member
 
Registered: Aug 2003
Posts: 234

Original Poster
Rep: Reputation: 30
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.

Last edited by wedgeworth; 10-14-2003 at 08:32 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron NOT running php script ??!! hendrixx Linux - Software 2 11-15-2006 07:18 AM
cron NOT running php script ??!! hendrixx Programming 1 01-19-2005 05:36 AM
script not running as a cron job sanjith11 Programming 5 11-23-2004 08:42 AM
cron error when running script? meeble Linux - Software 3 09-09-2004 05:00 PM
running a 'dcop' script from 'cron' dsunger Linux - Software 0 05-10-2004 01:17 AM


All times are GMT -5. The time now is 05:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration