Hi all,
i am facing some problem while using send in expect (tcl).
problem:
1. in linux machine i am running some process refelct: for getting the process id of all the reflect processes i m using
ps -aef | grep reflect | grep -v grep | awk '{print $2}'
which will return something like
19768
19546
10465
2. same thing i want to do with the help pf expect , here is my code
proc monitor_server {ip_server} {
source "/cygdrive/e/ncp/pat/pat_config.exp"
set cmd1 {ps -aef | grep reflect | grep -v grep | awk '{print $2}'}
if {[catch { spawn ssh $ip_server -l root } res]} {
puts $res
return 0
} else {
expect -re "(yes/no)"
send "yes\r"
sleep 1
expect -re "root@$ip_server's password: "
send "$passwd_testbed\r"
expect -re ".*# " {
send " $cmd1 \r"
expect -re "/\d\n"
puts $expect_out(0,string)
} }
}
this code is working up to executing the command, but when the command is getting executed , i want to get the out put in variable $expect_out(0,string).
may be i need some kind on pattern matching for that or is there any other way to get the result in some variable while i send the $cmd (i mean result of the command).
as i am new to tcl and expect.
thanks in advance
tanuj