Sponsored Content
Special Forums UNIX and Linux Applications waiting for ssh response for seconds Post 302293482 by vguleria on Tuesday 3rd of March 2009 07:04:12 AM
Old 03-03-2009
Thanks for the solution . It works gr8. Smilie


Quote:
Originally Posted by Gee-Money
Not sure if there is an SSH option for that, however, there is the 'netcat' utility, which you can connect to a certain post, and you can set a timeout.

For instance:

Code:
netcat -z -w <timeout in seconds> <host> <port>

So to check to see if ssh will respond withing 5 seconds, so the following:

Code:
netcat -z -w 5 host.example.com 22 || /bin/some_custom_alert

The '-z' option will make it disconnect as soon as it makes a connection to the port, and of course '-w' is to set the timeout in seconds.

If it does not connect, it will return a non-zero exit status, in which case, you would know to raise your alarm.

Hope this helps...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read-waiting for user response

Would there be any reason for why a 'read ans' would not wait for a user's response (i.e user has to hit a key to continue)? I know for sure that it is doing everything else in that part of my 'if' statement but it doesn't wait for me to hit a key before continuing. The strange thing is that... (4 Replies)
Discussion started by: giannicello
4 Replies

2. Shell Programming and Scripting

Looping and waiting

Hi Is it possible to have a script run in a loop (waiting for a change of state in the network interface), and if the loop continues for five minutes, to have it email the admin, and carry on in the loop? Here is my loop: #!/bin/bash STATE=`echo "show... (3 Replies)
Discussion started by: mikie
3 Replies

3. Shell Programming and Scripting

waiting

I have a text file which contain all the parameters need for scheduled jobs, then this "control" script would be called everynight at certain time while read line do $myScript.sh $line & pid=$! i=`expr $i + 1` done < $list then I need to wait until all... (1 Reply)
Discussion started by: mpang_
1 Replies

4. Shell Programming and Scripting

how do I handle ssh response with expect

I am trying to write an expect script that trys to telnet, if telnet fails, trys to ssh to a remote network devices. The script works fine until the following is received : spawn telnet 10.3.2.24 Trying 10.3.2.24... telnet: connect to address 10.3.2.24: Connection refused 10.3.2.24 is... (2 Replies)
Discussion started by: popeye
2 Replies

5. Shell Programming and Scripting

not waiting

I have a script that runs Compressor and converts the file then I want it to inject the file with Flvtool2. My script works fine but the flvtool2 is starting too early. I have tried to put it in the background by putting a "&" sign at the end and then put a "wait" on a new line. Anyone have any... (2 Replies)
Discussion started by: mainegate
2 Replies

6. Shell Programming and Scripting

not waiting...why?

My shell script is not waiting. I right click on a file and say convert it to whatever and it runs this script. It converts it using Compressor but I want it to wait until it is 100% done before moving on and it is not waiting. I have tried to put it in the background and using "wait". I have tried... (10 Replies)
Discussion started by: mainegate
10 Replies

7. Shell Programming and Scripting

Capture RSA fingerprint from ssh response

Hi. I'm trying to automate access to an Amazon Web Services machine instance. What this means is that my script is trying to use ssh to connect to a new server every time. I know the RSA fingerprint of my new server through an out-of-band channel. I would like to capture the RSA fingerprint... (0 Replies)
Discussion started by: chorlton
0 Replies

8. UNIX for Advanced & Expert Users

ssh error: Error reading response length from authentication socket

Hi - I am getting the error `Error reading response length from authentication socket' when I ssh from my cluster to another cluster, and then back to my cluster. It doesn't seem to affect anything, but it's just annoying that it always pops up and tends to confuse new users of the cluster. I... (1 Reply)
Discussion started by: cpp6f
1 Replies

9. Shell Programming and Scripting

How to skip command if it is hanging while waiting for response

Hello, I have a script that contains the command "whois 1.2.3.4" Sometimes this command takes far too long to produce any output and as a result the rest of the script is not executed. Can anyone suggest a method so that if no output is produced after say 2 seconds the script skips that... (2 Replies)
Discussion started by: colinireland
2 Replies

10. UNIX for Dummies Questions & Answers

passing input into a cmd line that's waiting for a response

Hi, I am writing a little script to update a parameters on JMQ. however the JMQ requires a "y" confirmation to be input as part of the cmd I am running. However I want run this script to offline with no input from a user. it works if a I create a file with with just y in it and pass that in... (3 Replies)
Discussion started by: shropshirehobbi
3 Replies
corkscrew(1)							    Networking							      corkscrew(1)

NAME
corkscrew - Tunnel TCP connections through HTTP proxies SYNOPSIS
corkscrew PROXY PROXYPORT TARGETHOST TARGETPORT [AUTH_FILE] DESCRIPTION
corkscrew is a simple tool to tunnel TCP connections through an HTTP proxy supporting the CONNECT method. It reads stdin and writes to std- out during the connection, just like netcat. It can be used for instance to connect to an SSH server running on a remote 443 port through a strict HTTPS proxy. PROXY The name of the host running the HTTP proxy. PROXYPORT The port on which to connect on the proxy. TARGET The host to reach through the proxy. TARGETPORT The port to connect to on the target host. AUTH_ FILE The auth file is made of one single line containing your username and password in the form username:password OPTIONS
None. EXAMPLES
The common usage of corkscrew is to put the following line in ~/.ssh/ssh_config: ProxyCommand corkscrew proxy proxyport %h %p [<path to auth_file>] This will let the ssh connection go through the proxy with the help of corkscrew. ENVIRONMENT
None. FILES
None. SEE ALSO
ssh_config(5) AUTHORS
Program was written by Pat Padgett <agroman@agroman.net>. This manual page was written by Laurent Fousse <laurent@komite.net> for the Debian GNU system (but may be used by others). Updated by Jari Aalto <jari.aalto@cante.net>. Released under license GNU GPL version 2 or (at your option) any later version. For more information about license, visit <http://www.gnu.org/copyleft/gpl.html>. corkscrew 2012-03-26 corkscrew(1)
All times are GMT -4. The time now is 10:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy