LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Expect Not Showning Spawned instance Output (https://www.linuxquestions.org/questions/linux-desktop-74/expect-not-showning-spawned-instance-output-4175441496/)

wesweber 12-14-2012 05:59 PM

Expect Not Showning Spawned instance Output
 
I'm trying to automate a SSH connection to a device and retrieve a status periodically. My script appears to run, I get logged on to the device and and the commands appear to run. The problem is I'm not seeing any of the output from the commands. I've tried expect_user, expect_tty and tried some redirection, tried writing the expect buffer to a file but nothing. Below is the script. Any suggestions would be appreciated.

#! /usr/bin/expect
spawn ssh -t username@devicename
expect "password:"
send "passwordstring\r"
expect ">"
send "show ospf neighbor\r"
expect ">"
send "show route next-hop xx.yy.zz.aa"
expect ">"
send "exit"

When I run the script it spawns the ssh and displays the spawn line, then the password, on the next line it shows the "show ospf neighbor" command and the "show route next-hop" command and finally "exit" and I get the shell prompt back.
I would like to see or at least save the output from the commands.


All times are GMT -5. The time now is 11:13 AM.