Sponsored Content
Full Discussion: EXCEPT timeout problem
Top Forums Shell Programming and Scripting EXCEPT timeout problem Post 302391789 by fedora on Tuesday 2nd of February 2010 01:58:05 PM
Old 02-02-2010
EXCEPT timeout problem

i am trying to write an except script to ssh into a list of devices and run some commands, and i came across this problem, not every device is alive, which breaks the script, my script looks like this
Code:
#!/usr/bin/expect                           
# set defaults                              
set device [lindex $argv 0]                 

set user "admin"
set password "test123"
set list [open $device r] 
set resultfile [open setlog.log w]
set timeout 10                    
trap exit SIGINT                  

log_file -a -noappend setlog_logfile.log

# ssh to each IP on the list

while {[gets $list line] != -1} {
set pid [spawn ssh -o "ConnectTimeout 3" admin@$line]  
expect "password:"               
send "$password\r"               
expect eof                       
expect "#"                       
send "shell\r"                   
****some commands here****
send "exit\r"                             
expect eof                                
puts $resultfile "$line, Worked!"         
log_user 1                                
wait                                      
}

following is the error message i got, apparently expect runs across a dead ip and it times out and *continue* to run the next command in the script, how can i fix this? thanks
Code:
$ ./testrun /tmp/testip
spawn ssh -o ConnectTimeout 3 admin@192.168.1.2
ssh: connect to host 192.168.1.2 port 22: Connection timed out
send: spawn id exp9 not open
    while executing
"send "$password\r"               "
    ("while" body line 4)
    invoked from within


Last edited by Scott; 02-02-2010 at 03:06 PM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. HP-UX

timeout

How can I kick a user out after being idle for a certain amount of time, would prefer not to use scripts, will TMOUT work on HP-UX? (5 Replies)
Discussion started by: csaunders
5 Replies

2. Solaris

About the Timeout

Hello everyone I am a new one,I want to know how to get the solaris force the loginer out if he do not in a time thanks (4 Replies)
Discussion started by: lyh003473
4 Replies

3. Filesystems, Disks and Memory

timeout problem

Hi can anyone help with the following:- when sending large e-mails via a ssh session the job always times out every 5 min before the mail is sent, this means that a user has to tap a key to stop it timming out. Is there a way to stop this from happening. Numpty (4 Replies)
Discussion started by: numpty
4 Replies

4. UNIX for Advanced & Expert Users

timeout opening writing control channel /dev/initctl problem occur i cant shoudown

Hi... This is message that occurs when i am trying to shutdown the linux system timeout opening writing control channel /dev/initctl how can i shutdown what is the problem here.. Thanks in advance ... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

5. Shell Programming and Scripting

how to set timeout?

When I run a script where the 1st parameter is ip address ftp -n -i -v $1 I hang here if the ip is wrong how to set a timeout something like if (20s not complete "ftp -n -i -v $1") then echo "error" fi Thanks a lot. (14 Replies)
Discussion started by: uativan
14 Replies

6. Shell Programming and Scripting

sftp expect timeout problem

hello All, I am doing SFTP using expect. We just change our server from sun solaris 8 to sun solaris 10. The script was working good on sun solaris 8. But it is giving problem on 10. from shell, SFTP is working fine.Please help me. What can be the problem. LIB_sftp_get() { ... (0 Replies)
Discussion started by: mindtee_abhi
0 Replies

7. Red Hat

Freezing, Request Timeout - performance problem

Hi, The server is Redhat 5 32bit. It is not easy to produce the problem so I will just write the experienced problems not how it is produced. 1) During login, it shows the last login time and then waits for 3-4 seconds to give shell prompt (considerable) 2) Sometimes the connection window... (2 Replies)
Discussion started by: royalliege
2 Replies

8. Shell Programming and Scripting

Setting a Timeout

Hi I'm writing a script which based on a condition, restarts a set of servers. The problem I'm facing is, say if one of the server is down, my script stops there and fails to proceed. How can I ensure to set a timeout value on that script, so when the server is not reachable, the script should... (2 Replies)
Discussion started by: mathbalaji
2 Replies

9. Shell Programming and Scripting

Expect timeout

Hello, I'm doing a simple script with expect (a telnet which works without user/pass), and I want to put a condition if timeout happens, then to print a message, but it doesn't work. The script looks like below: #!/usr/bin/expect log_user 0 set timeout 10 spawn telnet IP PORT send... (3 Replies)
Discussion started by: rainbow19
3 Replies
SSH-ARGV0(1)                                                BSD General Commands Manual                                               SSH-ARGV0(1)

NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling SYNOPSIS
hostname | user@hostname [-l login_name] [command] hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name] [-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command] DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally. OPTIONS
See ssh(1). FILES
See ssh(1). AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation. SEE ALSO
ssh(1) Debian Project September 7, 2001 Debian Project
All times are GMT -4. The time now is 09:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy