expect wait --More-- string and exit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting expect wait --More-- string and exit
# 1  
Old 11-13-2009
expect wait --More-- string and exit

Hi

I am programing a expect script on debian, I connected to a firewall to get configuration copy via telnet or ssh but Because of firewall show configuration console wait and print --More-- need press space key at least 100.Help me please.

firewall output like this Smilie
Quote:
-------------------------------------
firewall#show config
config line 1
config line 2
config line 3
config line 4
config line 5
config line 6
-----More--
This output isn't firewall full config and expect script wait and exit.Thus my expect script not run that I want.

my expect script is like this

Code:
***************expect.sh**********
#!/bin/expect
spawn telnet 10.1.1.1

expect -re "Login" {
                send "admin";
                }  

expect -re "Password" {
                send "123";
                }

expect -re "firewall#" {
                send "show config";
                }
exit
***********bash command***********
Debian#./expect.sh > backupfirewall.cfg
**********************************


Last edited by Neo; 11-13-2009 at 03:24 PM.. Reason: format please: use code and quote tags!
# 2  
Old 11-13-2009
My first thought is that you need to introduce a while statement in your expect script to read the troublesome -----More-- text and send a carriage return when it happens.
# 3  
Old 11-13-2009
Quote:
Originally Posted by Neo
My first thought is that you need to introduce a while statement in your expect script to read the troublesome -----More-- text and send a carriage return when it happens.


Hi
Please show me on my script correct form.
# 4  
Old 11-13-2009
Quote:
Originally Posted by ayucelen
Hi
Please show me on my script correct form.
You should do your work and post your attempt to write a script and not simply ask people to do your work for you. I have given you the basic idea, so I suggest you do some of your own work first and attempt to solve your problem yourself and post back your work.
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

Make expect exit the UNIX script in erreneous condition

Hi, I am writing a menu driven program using shell script. THe script will be collecting data by logging into the other servers and bringing back the data to home server to process it and accordingly issue commands. TO automate commands execution , I am using expect script. However I am not able... (5 Replies)
Discussion started by: ashima jain
5 Replies

3. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

4. Shell Programming and Scripting

expect ssh script cannot finish and exit

All i am new to linux, and try to have a simple expect script to ssh then telnet to the network equipment, and exit itself. but dont know why i hang at the last $ #!/usr/bin/expect set timeout 10 set arg set arg1 spawn ssh -l UserA 1.1.1.1 expect "assword:"; send "PasSwOrD\r";... (1 Reply)
Discussion started by: samoptimus
1 Replies

5. Shell Programming and Scripting

Expect script: obtain the exit code of remote command

Hi all, I'm trying to run the sipp simulator in crontab but after some attempt I came to the conclusion that for some reason this isn't possible (maybe due to sipp interactive nature). This is confirmed by these posts. Now I'm trying to launch sipp from an expect script that runs in crontab. ... (0 Replies)
Discussion started by: Evan
0 Replies

6. Shell Programming and Scripting

Is there a way to ask expect wait for sometime before running the next send command ?

Hi all, After expect catches the string I specify, is there a way to ask expect wait for sometime before running the next send command ? So my script looks like following, expect "some string" #How to ask expect to wait for a while send "next command" The reason I want to do this is... (0 Replies)
Discussion started by: qiulang
0 Replies

7. UNIX for Advanced & Expert Users

expect-string length problom

hi i am writing an expect script to automate su command, my script goes like this... #!/usr/local/bin/expect -- set password set env_var spawn su UNAME expect "password:" send "$password\r" expect "env" send "setenv PATHVAR $env_ver\r" expect "env" send "echo \$PATHVAR" expect eof ... (2 Replies)
Discussion started by: sudheer157
2 Replies

8. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

9. Shell Programming and Scripting

check exit status - Expect Script

from my main script, i am calling an expect script. there are a lot of conditions in the Expect script and it can have any exit value based on success or failure of the Expect Script. how can i check the exit status of Expect scritp in the main script. (1 Reply)
Discussion started by: iamcool
1 Replies
Login or Register to Ask a Question