Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote devices send out EOF when running in cron?

Status
Not open for further replies.

fedorafan

ISP
Jul 1, 2006
5
US
I am writing an expect script which sshs into some special network devices and grab some files.

When i manually run it there is not problem at all, but when I put the same expect script into cron, i get randomly "EOF" being sent from the device as soon as the passwd gets sent to the device.

Can anyone take a look at my script and tell me what should i do to make the cron work?(i tried to set the term type and did not work)

The core part of the expect script looks like this,

while {[gets $list line] != -1} {

spawn ssh -t admin@$line
expect {
"password:" {
send "$password\r"
expect "admin"
send "shell\r"
expect {
"ksh" {
send "cat /tmp/status.txt\r"
expect "commands"
send "exit\r"
expect "admin"
send "exit\r"
}
eof {wait}
}
}
timeout {break}
}
}


and the error message is like this:

expect: does "@06:/# " (spawn_id exp13) match glob pattern "ksh"? no
shell

expect: does "@06:/# shell\r\n" (spawn_id exp13) match glob pattern "ksh"? no
Connection to a.b.c.d closed.

expect: does "@a.b.c.d:/# shell\r\nConnection to a.b.c.d closed.\r\r\n" (spawn_id exp13) match glob pattern "ksh"? no
expect: read eof
expect: set expect_out(spawn_id) "exp13
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top