How can I scroll the terminal output with Expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can I scroll the terminal output with Expect
# 1  
Old 12-15-2010
How can I scroll the terminal output with Expect

Hi,

I'm trying to come up with a simple expect script that allows me to login to a system and run a single command ... something like this:

Code:
#!/usr/bin/expect -f
# let's set some variables
#set password [lrange $argv 0 0]
set ipaddr [lrange $argv 0 0]
set ponumber [lrange $argv 1 1]
set hostname [lrange $argv 2 2]
set timeout -1
# let's now connect to the system
spawn telnet $ipaddr
match_max 100000
# we now look for the password prompt.
expect "*login:*"
send -- "admin\r"
expect "*assword:*"
send -- "yourpassword_here\r"
log_file /archive/$ponumber/$hostname.txt
expect "MVBLGS11>"
send -- "show config\r"
expect ">"
send -- "exit\r"
expect eof

The problem I have is that the output from a single show command overflows, the display screen is followed by the --More-- prompt. At the --More-- prompt, you have these options:

- Press Ctrl+C, q, or Q to interrupt the output and return to the command prompt.

- Press the spacebar to display an additional screen of output.

- Press Enter to display one more line of output.

What I want at the end is to record all the output from the show command but my script is timing out at the first --More-- prompt. How can I make the script to send new line characters (i.e. spacebar) everytime it gets the --More-- prompt?

Thanks in advance,

Dan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

A means of clearing the scroll buffer in an OSX Terminal.

I was looking for a method of clearing the buffer of the vertical scroll back slider and came across this little Terminal escape snippet I had never seen before: printf "%b" "\033 SO... printf "%b" "\033c\033 Performs a terminal reset, buffer clearance, clear the window, set back to default... (0 Replies)
Discussion started by: wisecracker
0 Replies

2. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

3. UNIX for Dummies Questions & Answers

Unable to scroll to the top of the output of a command

Hello, I am a beginner, I have currently Solaris 11 on a vmware machine. Whenever I type a command like 'ls' the screen scrolls to the end of the screen. I am unable to see the entire list of directories and files. I have tried ls |page command, but looking out for a better option. (3 Replies)
Discussion started by: farheenprasad
3 Replies

4. Shell Programming and Scripting

Expect debug output

Hi! I want to start OO in headless mode via expect - the oo command would be su - root -c "/usr/lib/openoffice/program/soffice -headless -nofirststartwizard -norestore -nolockcheck -nocrashreport -nodefault -accept='socket,host=0.0.0.0,port=8100;urp;StarOffice.Service'" and the expect... (2 Replies)
Discussion started by: senior.weber
2 Replies

5. Shell Programming and Scripting

Expect - Interact output hangs when large output

Hello, I have a simple expect script I use to ssh to a workstation. I then pass control over to the user with interact. This script works fine on my HP and Mac, but on my Linux Desktop, I get a problem where the terminal hangs when ever I execute a command in the interact session that requires a... (0 Replies)
Discussion started by: natedog
0 Replies

6. UNIX for Dummies Questions & Answers

Seeing the screen output beyond the scroll capability for the last run command

HI , I forgot to redirect my op to a file.The op which is quite huge , thus printed on the screen.However bcoz of the limited viewing in the screenI can not see the whole of the output.. Is there anyway I can see the full op.My run takes half a day for finnishing ..So I am refraining... (1 Reply)
Discussion started by: bimukt
1 Replies

7. Shell Programming and Scripting

Expect Terminal Macros

Hey people! I just started out working at an ISP as tech support and thought that I should ease the work load by scripting some small macros. I create different commands with Alias through .bashrc which are all directed to the same script file. Here I planned on using Expect to run different... (0 Replies)
Discussion started by: GhettoFish
0 Replies

8. Shell Programming and Scripting

want to use output of c programme in expect

hi i am having a c code which gives the output of my password in text format i.e when i run my c code which which gives the password asfollows====>>>>>> $./passwdprogram ======>>>>>>abc@123(this is the output) now i have an expect script to remotely ssh which uses the password set in ... (0 Replies)
Discussion started by: xander
0 Replies

9. Shell Programming and Scripting

Get the output from EXPECT ?

I'm using expect script, but don't know how to assign an output to a string variable. Any help ? Thank you for reading! PS: In fact i want to get the out put of expect when run grub-md5-crypt to generate MD5 password for GRUB boot loader. My code:#!/bin/sh #\ exec expect -f "$0" ${1+"$@"}... (4 Replies)
Discussion started by: fongthai
4 Replies

10. Programming

output to terminal

How can I write to another user's pseudo tty, but not to its current prompt position (as in open("/dev/pts007", ...) followed by write() ). Instead I would like to write to the top center of the screen using color red, for example. Like curses, but from another console. (6 Replies)
Discussion started by: andreis
6 Replies
Login or Register to Ask a Question