expect script doesn't work with cron - please help 
Author Message
 expect script doesn't work with cron - please help

Hi,

I have a script that connects to various machines via scp and pulls files
from them.  I have only been using
expect for a few days so excuse any silly obvious problems with my code

I have a shell script that calls the expect script on Solaris 2.7

This works from the command line but whilst it executes from cron, it
doesn't copy the
files over although the output otherwise looks identical in the logs.  I
think the send part
doesn't execute from cron - why ?

Code show below

Calling script

#!/bin/sh
lineno=1
DATE=`date +%Y-%m-%d`
cd /LOGS/custlogs
while [ $lineno -ne 0 ]
do
        fw=`./getline $lineno firewall-list`
        if [ "$fw" != "" ]
        then
                ./inti.exp $fw
                fw=""
                lineno=`expr $lineno + 1`
        else
                lineno=0
        fi
done

Expect Script

set env(TERM) vt100
set day [exec date +%d]
set month [exec date +%m]
set year [exec date +%Y]
set date "$day-$month-$year"
set logfile [open failedhosts a]
set timeout 5
set FW_IP $argv

/LOGS/custlogs/$FW_IP/
expect {
        timeout {puts $logfile "$FW_IP $date"; exit}
        ".co.uk':" {send "#######\r"}

Quote:
}

interact
close $logfile

Cron job below

55 23 * * * su logshift -c '. /LOGS/custlogs/.profile;
/LOGS/custlogs/getlogs > /LOGS/custlogs/getlogs.log'

Any ideas and all responses will be greatly appreciated.

kind regards
Inti



Mon, 04 Aug 2003 02:18:05 GMT  
 expect script doesn't work with cron - please help

Quote:

> I have a script that connects to various machines via scp and pulls files
> from them.  I have only been using
> expect for a few days so excuse any silly obvious problems with my code

> I have a shell script that calls the expect script on Solaris 2.7

> This works from the command line but whilst it executes from cron, it
> doesn't copy the
> files over although the output otherwise looks identical in the logs.  I
> think the send part
> doesn't execute from cron - why ?

> Code show below

> Calling script

> #!/bin/sh
> lineno=1
> DATE=`date +%Y-%m-%d`
> cd /LOGS/custlogs
> while [ $lineno -ne 0 ]
> do
>         fw=`./getline $lineno firewall-list`
>         if [ "$fw" != "" ]
>         then
>                 ./inti.exp $fw
>                 fw=""
>                 lineno=`expr $lineno + 1`
>         else
>                 lineno=0
>         fi
> done

> Expect Script

> set env(TERM) vt100
> set day [exec date +%d]
> set month [exec date +%m]
> set year [exec date +%Y]
> set date "$day-$month-$year"
> set logfile [open failedhosts a]
> set timeout 5
> set FW_IP $argv

> /LOGS/custlogs/$FW_IP/
> expect {
>         timeout {puts $logfile "$FW_IP $date"; exit}
>         ".co.uk':" {send "#######\r"}
> }
> interact
> close $logfile

> Cron job below

> 55 23 * * * su logshift -c '. /LOGS/custlogs/.profile;
> /LOGS/custlogs/getlogs > /LOGS/custlogs/getlogs.log'

> Any ideas and all responses will be greatly appreciated.

> kind regards
> Inti

What do you expect that "interact" in your Expect script to do under
cron?

Don



Mon, 04 Aug 2003 05:53:37 GMT  
 expect script doesn't work with cron - please help


Quote:

> > I have a script that connects to various machines via scp and pulls
files
> > from them.  I have only been using
> > expect for a few days so excuse any silly obvious problems with my code

> > I have a shell script that calls the expect script on Solaris 2.7

> > This works from the command line but whilst it executes from cron, it
> > doesn't copy the
> > files over although the output otherwise looks identical in the logs.  I
> > think the send part
> > doesn't execute from cron - why ?

> > Code show below

> > Calling script

> > #!/bin/sh
> > lineno=1
> > DATE=`date +%Y-%m-%d`
> > cd /LOGS/custlogs
> > while [ $lineno -ne 0 ]
> > do
> >         fw=`./getline $lineno firewall-list`
> >         if [ "$fw" != "" ]
> >         then
> >                 ./inti.exp $fw
> >                 fw=""
> >                 lineno=`expr $lineno + 1`
> >         else
> >                 lineno=0
> >         fi
> > done

> > Expect Script

> > set env(TERM) vt100
> > set day [exec date +%d]
> > set month [exec date +%m]
> > set year [exec date +%Y]
> > set date "$day-$month-$year"
> > set logfile [open failedhosts a]
> > set timeout 5
> > set FW_IP $argv

> > /LOGS/custlogs/$FW_IP/
> > expect {
> >         timeout {puts $logfile "$FW_IP $date"; exit}
> >         ".co.uk':" {send "#######\r"}
> > }
> > interact
> > close $logfile

> > Cron job below

> > 55 23 * * * su logshift -c '. /LOGS/custlogs/.profile;
> > /LOGS/custlogs/getlogs > /LOGS/custlogs/getlogs.log'

> > Any ideas and all responses will be greatly appreciated.

> > kind regards
> > Inti

> What do you expect that "interact" in your Expect script to do under
> cron?

> Don

on the command line without the interact it doesn't work.  It seems that
this won't work in
cron anyway from your feedback.  OK...How do I get my expect line to send
and timeout
when it can't connect to a device in the list too.  The timeout works but
send doesn't unless
I have a interact statement.  Any help would be appreciated as I am very new
to using expect

Sorry if the code looks stupid.

Inti.



Mon, 04 Aug 2003 18:30:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Expect script doesn't work !!

2. expect script not working - please help

3. re.LOCALE | re.IGNORECASE doesn't work as you'd expect

4. expect's full_buffer doesn't seem to work

5. BLT installs but doesn't work, and TkTable doesn't build

6. tkterm script written in expect doesn't get inforamtion from other interpt

7. Why doesn't this work as expected?

8. tcl/expect doesn't work unless I telnet into the machine

9. Why doesn't this work as expected?

10. Why doesn't my simple script work?

11. email script doesn't work

12. TclpFindExecutable doesn't work for CGI scripts under Apache

 

 
Powered by phpBB® Forum Software