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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on Expect

Status
Not open for further replies.

adamgower

Programmer
Jul 21, 2006
1
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top