Hi,
I am trying to use the Expect package commands to telnet to a machine and then execute certian commands on that.
I want to capture the output of each command executed in a variable. Currently I am using the log_file option as shown in the snippet below. However I am sure there must be a cleaner method using expect_out(buffer) but am not able to make it work.
please suggest,
------------------------------------
package require Expect
spawn telnet 172.26.20.70
set id $spawn_id
set a [expect $id login: ]
exp_send -i $id "dhingra\r"
expect $id Password:
exp_send -i $id "monikadhingra\r"
expect $id $
exp_send -i $id "ls\r"
expect $id $
exp_send -i $id "cat /home/dhingra/shell_scripts/first \r"
expect $id $
log_file output_log.log
exp_send -i $id "cat /home/dhingra/shell_scripts/first \r"
expect $id $
log_file
----------------------------------------------------
TIA
Atul
I am trying to use the Expect package commands to telnet to a machine and then execute certian commands on that.
I want to capture the output of each command executed in a variable. Currently I am using the log_file option as shown in the snippet below. However I am sure there must be a cleaner method using expect_out(buffer) but am not able to make it work.
please suggest,
------------------------------------
package require Expect
spawn telnet 172.26.20.70
set id $spawn_id
set a [expect $id login: ]
exp_send -i $id "dhingra\r"
expect $id Password:
exp_send -i $id "monikadhingra\r"
expect $id $
exp_send -i $id "ls\r"
expect $id $
exp_send -i $id "cat /home/dhingra/shell_scripts/first \r"
expect $id $
log_file output_log.log
exp_send -i $id "cat /home/dhingra/shell_scripts/first \r"
expect $id $
log_file
----------------------------------------------------
TIA
Atul