Confirmation rather than "sleep"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Confirmation rather than "sleep"
# 1  
Old 11-27-2006
Confirmation rather than "sleep"

I have a simple telnet script that logs into a device and issues a number of commands with "sleep" between each command. This works great, although it would be nice to execute each command based on a response rather than an assummed sleep time?

The reponse received is "COMPLD" which could trigger the next command. Here is a similar example script with "sleep" in between each command.

Thanks.

--------------------------------------------
#!/bin/sh
host=10.1.2.2
login=admin
password=admin

command1="show software"
command2="show card software"
command3="conf t1 state up"
{
echo "$login""\r"
sleep 2
echo "$password""\r"
sleep 2
echo "$command1""\r"
sleep 2
echo "$command2""\r"
sleep 2
echo "$command3""\r"
sleep 2
echo "Y""\r"
sleep 3
echo "exit""\r"
}| telnet $host
# 2  
Old 11-27-2006
I think you are looking for "expect" scripts. expect is a scripting language like shell or perl and you need to install it as a package.

John Arackal
# 3  
Old 11-27-2006
There is nothing in a shell script that can act upon the return of a set of characters?

I will install Expect and brush-up.....
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Solaris

Do Linux "Sleep Mode" Problems Happen on UNIX?

I am an experienced MS Windows user who has tried four different flavors of Linux: Mandriva, Centos, Debian, and Ubantu---each on a different PC. (I always used a dual-boot configuration with Grub and Win XP or Win 7). Each time, I encountered the following two problems: While resuming from... (2 Replies)
Discussion started by: mjdz
2 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

How to implement "sleep" in Perl ?

I tried, #!/usr/bin/perl print "check 1"; print "check 2"; sleep(5); The above works fine but sleep takes the higest priority. Looks weird In above program "sleep" executes first and then "print" comes next. I would like the program to be executed in "sequence" , Print at first and then... (3 Replies)
Discussion started by: frintocf
3 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

question about "sleep" command in expect script

I wrote some expect script to telnet to some device to execute some commands.Firstly,I can't get full result some time,then I try to add some "sleep" command in it.Fortunately it works. My idea about it is that it uses sleep command to wait the result to be displayed.Am I right or correct the... (4 Replies)
Discussion started by: robbiezr
4 Replies

8. Shell Programming and Scripting

How could I disable "kill" confirmation message

Hello every body, Before terminating a script by saying "Good Bay", I need to kill all child processes which I already done successfully. The problem is: users of the scripts still see the confirmation message as it can be seen below: =========================================================... (2 Replies)
Discussion started by: SultanKSA
2 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question