Expect While Loops - Partial Automation?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect While Loops - Partial Automation?
# 1  
Old 10-14-2011
Expect While Loops - Partial Automation?

I've been reading the O'Reilley expect book and I'm trying to create partial automation for common questions asked on screen in a telnet session and return to interact so the user can resume control.


For example

Code:
while {1} {
     expect {
        -re "What color is the sky?" {send "blue\n"}
        -re "Should you touch a hot stove?" {send "no\n"}
        -re "DNS Server:" {send "4.2.2.1\n}
        -re "##alias" {send "do stuff\nthen stuff\n"}
         interact + return
        }


Can I have an automatic loop that will let me interact with the telnet session and pick up automation when these key questions are asked and will the alias work if I type ##alias in the interact part of the session?


Thanks

Last edited by pludi; 10-14-2011 at 07:05 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

2. Shell Programming and Scripting

korn shell for loops with expect issue

Hi I have the following Korn script having multiple for loops. #!/bin/ksh EXPECT=/usr/local/bin/expect exp_internal for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 i22 23 24 25 26; do for i in 01 02 03 04 05 06 07 ; do for h in 00 01 02 03 04 05 06 07 08 09 10 11 12... (2 Replies)
Discussion started by: cic
2 Replies

3. Shell Programming and Scripting

multiple while loops in expect script

Hi, I am trying to incorporate multiple while loops into an expect script written in ksh shell. This is on a Solaris 10 system. Here is the code: #!/bin/ksh EXPECT=/usr/local/bin/expect exp_internal i=1 h=0 while ]; do $EXPECT << DONE set stty_init raw ... (1 Reply)
Discussion started by: cic
1 Replies

4. Shell Programming and Scripting

Expect script - going in loops can't stop

Hi First of all I tried lot of forums to create my first expect script. But I am totally stumped at the last step. I am no Linux Admin or ever trained in Linux. I just tried to create the script logically History : I need to to change my password across lot of servers in Linux over ssh ... (4 Replies)
Discussion started by: radioactive9
4 Replies

5. Shell Programming and Scripting

EXPECT script for Telnet automation. Need your support.

Dear experts, please help me . I've found simple EXPECT scripts and all works fine. But I need more automation in error handling and sending list of commands/output logging from multiple remote hosts. I have 10 hosts, for example: host1 192.168.1.1 LOGIN1 PASSWORD1 ...... ... (2 Replies)
Discussion started by: starchen
2 Replies

6. Shell Programming and Scripting

AWK - Print partial line/partial field

Hello, this is probably a simple request but I've been toying with it for a while. I have a large list of devices and commands that were run with a script, now I have lines such as: a-router-hostname-C#show ver I want to print everything up to (and excluding) the # and everything after it... (3 Replies)
Discussion started by: ippy98
3 Replies

7. Shell Programming and Scripting

Expect - Comparison of expect value and loop selection

Hello All, I am trying to automate an installation process using expect and sh script. My problem is that during the installation process the expected value can change according to the situation. For Example if this is a first time installation then at step 3 I'll get "Do you want to accept... (0 Replies)
Discussion started by: alokrm
0 Replies

8. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

9. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies
Login or Register to Ask a Question
GNOME-SHELL(1)							    gnome-shell 						    GNOME-SHELL(1)

NAME
gnome-shell - Graphical shell for the GNOME desktop SYNOPSIS
gnome-shell [OPTION...] DESCRIPTION
GNOME shell provides core user interface functions for the GNOME 3 desktop, like switching to windows and launching applications. GNOME shell takes advantage of the capabilities of modern graphics hardware and introduces innovative user interface concepts to provide a visually attractive and easy to use experience. gnome-shell is a required component of the GNOME desktop, i.e. it is listed in the RequiredComponents field of /usr/share/gnome-session/sessions/gnome.session. It is started in the window manager phase of the session. OPTIONS
-r, --replace Replace the running window manager --sm-disable Disable connection to the session manager --sm-client-id=ID Specify session management ID --sm-save-file=FILE Initialize session from FILE --screen=SCREEN X screen to use -d, --display=DISPLAY X Display to use --sync Make X calls synchronous --version Print version and exit --help Display help and exit --mode=MODE Use a specific mode, e.g. "gdm" for login screen --list-modes List possible modes and exit --clutter-display=DISPLAY Clutter the option display (otherwise ignored) FILES
/usr/share/gnome-session/sessions/gnome.session, /usr/share/applications/gnome-shell.desktop. BUGS
The bug tracker can be reached by visiting the website https://bugzilla.gnome.org/buglist.cgi?product=gnome-shell. Before sending a bug report, please verify that you have the latest version of gnome-shell. Many bugs (major and minor) are fixed at each release, and if yours is out of date, the problem may already have been solved. ADDITIONAL INFORMATION
For further information, visit the website http://live.gnome.org/GnomeShell. gnome-shell GNOME-SHELL(1)