Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 12-14-2012, 05:59 PM   #1
LQ Newbie
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect: Handling multiple spawned processes from a single script rajivk Programming 0 02-05-2012 03:13 PM
Can expect return control of a spawned process to a shell script? duffrecords Programming 4 04-28-2010 02:33 PM
Expect: Prevent output from spawned process to appear on stdout jlinkels Programming 3 08-12-2009 09:20 PM
expect says it cant send the string to the spawned command exceed1 Programming 0 01-17-2009 06:51 AM
vpnc spawned from "expect" killed upon exit saravkrish Linux - General 1 01-29-2007 08:17 PM > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration