SSH Is hanging and the & sign does not seem to be working

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support SSH Is hanging and the & sign does not seem to be working
# 1  
Old 10-24-2011
SSH Is hanging and the & sign does not seem to be working

I am having an issue where I am do an SSH to about 30 servers one at a time however my script is getting hung up sometimes on the SSH.
I thought the & at the end as seen below would fire it and move on but that does not seem to be working.


Code:
#!/bin/sh
for remsys in trumpetsnail angel delphin kraken bluemarron penguinshrimp moccasin roughgreen bluegarter eastindigo penribbon ringneck banded bl
ackracer applesnail skimmerclam seaclam
do
/lcl/tools/bin/sshPing.pl $remsys
VAR=$`/usr/bin/ssh $remsys "/lcl/apps/Tivoli/netcool/omnibus/bin/syslog_mon.sh" 2>&1 &`
Results=${VAR}
echo $Results
done


Any ideas?

Last edited by LRoberts; 10-24-2011 at 12:01 PM..
# 2  
Old 10-24-2011
The ssh connection will be waiting for the password to be supplied.

The solution for this is to exchange keys with the servers you are trying to login to, otherwise you need to supply password for each and every ssh to $remsys.

Also you first line is not correct, pass a proper shell.

Regards,
Vishal
# 3  
Old 10-24-2011
Passwording is not an issue. We use a .hosts file which allows for an SSH to each server from one another.
The first line was just a type'o in here. :-)

Any other ideas?
# 4  
Old 10-24-2011
What happens if you add a -n as option for ssh?
# 5  
Old 10-24-2011
You can't get a result from backticks if you put the thing into the background. To know what the output is, it has to be able to know what the output is -- i.e. either you'll get nothing, or it'll wait until it finishes.
# 6  
Old 10-24-2011
Correct but is there someway to make that timeout?
# 7  
Old 10-24-2011
Either have your script going for the timeout somehow or let ssh handle it (3 seconds for example):
Code:
ssh -o ConnectTimeout=3 ...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk: greater than sign is working upside down

Hi, I noticed a weird behaviour with awk. input: A|B|1-100|blabla_35_40_blabla;blabla_53_60_blabla;blabla_90_110_blabla Objective: For each string separated by ';' in $4, if the first and second numbers are included in the interval in $3, then print "TRUE". Otherwise print "FALSE". In... (3 Replies)
Discussion started by: beca123456
3 Replies

2. Red Hat

SSH not working

Hi, I have a server running RHEL 6.0. While logging in through root ,I can login.But if I try to login through "integ" user,I am unable to login. /var/log/secure messages::: May 20 15:25:23 punsyncserv su: pam_unix(su-l:session): session opened for user integ by root(uid=0) May 20 15:29:44... (4 Replies)
Discussion started by: nowornever
4 Replies

3. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

4. Solaris

SSH: internal working but external not working

Hi, This is a strange issue: We have an sftp server. Users can ssh to it from internal LAN without any issue, but they can not ssh to it externally via firewall. Here is what I got: OS is Solaris 9. No hosts.allow and hosts.deny files. Please help. Thank you in advance! (7 Replies)
Discussion started by: aixlover
7 Replies

5. Shell Programming and Scripting

SSH Script is sticking, & sign not doing what I would expect

I am having an issue where I am do an SSH to about 30 servers one at a time however my script is getting hung up sometimes on the SSH. I thought the & at the end as seen below would fire it and move on but that does not seem to be working. #!/bin/s for remsys in trumpetsnail angel delphin... (3 Replies)
Discussion started by: LRoberts
3 Replies

6. UNIX for Advanced & Expert Users

Awk expressions working & not working

Hi, Putting across a few awk expressions. Apart from the last, all of them are working. echo a/b/c | awk -F'/b/c$' '{print $1}' a echo a/b/c++ | awk -F'/b/c++' '{print $1}' a echo a/b/c++ | awk -F'/b/c++$' '{print $1}' a/b/c++ Request thoughts on why putting a '$' post double ++... (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies

7. Shell Programming and Scripting

Replace & sign to &amp word

Hi, I have text file abc.txt. In this file, I have the following data. Input: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith & Mrs Smith Mr Smith& Mrs Smith Mr Smith &Mrs Smith Output: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith &amp Mrs Smith Mr Smith&amp... (4 Replies)
Discussion started by: naveed
4 Replies

8. SuSE

ssh command on remote linux system hanging

Hi, Our systems: system1: amd 64 running suse linux 9 enterprize system2: amd 64 running esx vmware 3 with suse linux 9 enterprize. The problem is: when we ssh into system2 and execute the command: ls -al the session hangs. Infact session hangs when we execute any... (3 Replies)
Discussion started by: rajranibl
3 Replies

9. Shell Programming and Scripting

Sign on/Sign off logging script

I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem. I need... (1 Reply)
Discussion started by: Glider
1 Replies

10. Solaris

OS Problems -no DNS & SSH not working

I just installed Solaris 6/10 without any problems but I didn't connect the network cable when I installed it. Here are my problems: -I can access webpages using IP addrsses but not with domain names -ssh is installed but it is not running ('ps -e | grep sshd' didn't show it) I have been... (4 Replies)
Discussion started by: kungpow
4 Replies
Login or Register to Ask a Question