LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Space Key in Shell Script (http://www.linuxquestions.org/questions/linux-general-1/space-key-in-shell-script-148472/)

joshlamerritt 02-20-2004 01:22 PM

Space Key in Shell Script
 
I need my shell script to echo the space key in a telnet session. Here is script as I currently have it:

-----snip-----
#!/bin/bash
(
sleep 2
echo nevermore
sleep 2
echo en
sleep 2
echo chs008
sleep 2
echo "sh run"
sleep 4
echo " "
sleep 4
echo " "
sleep 4
echo " "
sleep 4
echo " "
) | telnet 10.8.1.100
-----snip-----

I am attempting to telnet to a Cisco switch and run the "sh run" command, which fills the screen and you must hit the space key to get the next full screen of data. I am running the script with as follows:

-----snip-----
[josh@seraph:~]$ ./telnet.script | tee tee.out
-----snip-----

This way I can capture the config of the switch. The script sort of works, but seems that it kills the telnet session when it gets to the second 'echo " " '.

Any help appreciated.

Josh

hw-tph 02-20-2004 01:31 PM

Perhaps you should looking into using expect instead. It is widely used for this sort of things, and writing expect scripts is often very straightforward.

Håkan


All times are GMT -5. The time now is 05:26 AM.