oopsie
The expect script works fine from the command prompt & even from zencommand run
interactively but bombs if run by the deamon due to the stty -echo command.
Anyway while tracking this down I revised it yet again to log to a file...
Code:
#!/usr/bin/expect --
set target [lrange $argv 0 0]
set user [lrange $argv 1 1]
set pwd [lrange $argv 2 2]
set cmd [join [lrange $argv 3 $argc] ]
set opkey [string range $cmd end-10 end ]
log_file -a /usr/local/zenoss/log/expect.log
log_file -info
log_user 0
send_log "\r\n--------------\r\n target=$target, user=$user, cmd=$cmd\r\n"
spawn -noecho telnet $target
#LOGIN
expect -re "ogin:" {send "$user\r"}
expect -re "assword:" {send "$pwd\r"}
expect "# " { send "$cmd\r" }
sleep 1
expect "$opkey\r\n" { }
expect "*\r\n" { send_user $expect_out(0,string) }
expect "# " { send "logout\r" }
log_file
NB this will APPEND to the log file so it will grow without limit - there is a
noappend option which will overwrite the log file or manage it some other way!!
enjoy...
-------------------- m2f --------------------
Read this topic online here:
http://forums.zenoss.com/viewtopic.php?p=36883#36883
-------------------- m2f --------------------
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users