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

Expect buffer

Status
Not open for further replies.

mrn

MIS
Apr 27, 2001
3,993
GB
I've got the following expect script

Code:
#!/usr/local/bin/expect -f
spawn telnet servera
expect "Login:"
send "username\r"
expect "Password"
send "password\r"
expect "Enter Selection"
send "1\r"
expect "servera#"
send "ls\r"
set results $expect_out(buffer)
send "exit\r"
expect eof

My question how do I read the buffer once expect has exited?

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
You have to write the results to a log file or suchlike and then parse this file after exiting expect.
 
I though $results would contain the buffer output, from what I've read.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
You're not looking for any output after the final send as far as I can see from your code snippet.

Code:
expect -re "(.*\n|.*\r)" {set results $expect_out(buffer)}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top