Hey guys, I have an Expect question. I'm trying to capture the result of a send back to the console after spawning a telnet to another server. Kinda like
spawn telnet servera
send $command
then display the result of the $command back to the console with out all the other login and prompt stuff.
I can put a log_user before and after the send command i.e.
log_user 1 ;#display to the console
send -- "$command\r"
expect timeout {send_user "Timed out waiting for prompt\n"; exit} -re $prompt
log_user 0 ;#do not display to the console
but it also sends the prompt back to the display. I thought the exec or system statement might do it but it runs the exec on the server I'm running the script from and not the server I've spawned to.
set result [exec $command]
send_tty $result
I'm basically writting an Tcl/Expect script to go out to all my servers (120+) and get info for reporting, i.e. oslevel or check cron entries whatever I set $command to. Everything works great I just would like to clean up the results so others can read it. Thanks in advance.
spawn telnet servera
send $command
then display the result of the $command back to the console with out all the other login and prompt stuff.
I can put a log_user before and after the send command i.e.
log_user 1 ;#display to the console
send -- "$command\r"
expect timeout {send_user "Timed out waiting for prompt\n"; exit} -re $prompt
log_user 0 ;#do not display to the console
but it also sends the prompt back to the display. I thought the exec or system statement might do it but it runs the exec on the server I'm running the script from and not the server I've spawned to.
set result [exec $command]
send_tty $result
I'm basically writting an Tcl/Expect script to go out to all my servers (120+) and get info for reporting, i.e. oslevel or check cron entries whatever I set $command to. Everything works great I just would like to clean up the results so others can read it. Thanks in advance.