[95581] in RedHat Linux List
Running expect script under cron
daemon@ATHENA.MIT.EDU (Mike A. Lewis, CNE)
Mon Oct 19 14:28:25 1998
From: "Mike A. Lewis, CNE" <cajun@cajuninc.com>
To: "'redhat-list@redhat.com'" <redhat-list@redhat.com>
Date: Mon, 19 Oct 1998 11:27:34 -0700
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
I've written an expect script to periodically check a device on our WAN.
The script works fine when executed from the command line, but when setup as
a cron job, it fails.
I've checked Don Libes FAQ's and found the following: "Here's one that
someone tried to stump me with recently: They told me that their program
started up and then Expect immediately exited. We spent a lot of time
tracking this down (Was the spawned program really starting up but then
hanging - which would indicate a bug in the program; or was the program NOT
starting up - which would indicate a bug in the environment; etc.) Turned
out that Expect wasn't even running their program. They had assumed cron
honored the #! line (which it doesn't) and so the first line in their script
(exec date) was being interpreted by the shell and of course, the script did
nothing after that - because that's what the shell's exec is supposed to
do!)
Now that is good information, except for one thing, it doesn't tell me what
the first line of the script should be.
Here's the script. Any help anyone can offer would be much appreciated.
Thanks,
Mike
#!/usr/bin/expect -f
set timeout 300
spawn telnet 10.39.25.1
expect "login: "
send root\r
expect "Password: "
send password\r\r
expect "host241# "
send "uptime | mail cajun@cajuninc.com\r"
send logout\r
expect "Connection closed by foreign host."
interact
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.