Hello "expect" experts
I am new at Expect. I have searched for a little while how to capture multiple lines with Expect and I am almost succeeded on that but I don't get all the lines of a command's output that the script executes on a server.
Here is how my script works in a nutshell -
The program establishes a ssh session into an Unix server and from there it runs another ssh into another server where a command is excuted on the final target server (after authentication is satisfied). The command produces an output with multiple lines (more than 30). My program only gets the last 10 or so lines of the output.
... Here are the important lines of the code that concerns me.
(1) expect -re "${promptvio}\$"
(2) send ${command2}\r
(3) expect -re "${promptvio}\$"
(4) puts "'$expect_out(buffer)'."
(5) send "exit\r"
(6) expect "login:"
(7) send "\~\.\r
In line (1), it expects a "$" prompt
In line (2), it sends a command to the server, which produces an output with multiple lines
In line (3), it expects again the "$" prompt
In line (4), it prints the contain of $expect_out(buffer) and this is the instruction that doesn't capture all the lines of the command.
Any help, would be appreciated.
Thanks