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.
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.
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.
What I do in my own parallel ssh script is redirect their output into individual files, background them, and wait for them individually. When they return, I read and delete the temp files.
I've never backgrounded a backtic expression before. That looks to me like a recipe for disaster. First, it won't do any parallelization of your foreground task. SecNod, you get no error code. But I think at least it closed STDIN which is why -n might be superfluous.
If you are still frustrated with this, I highly recommend the "pdsh" suite.. It actually parallelizes the ssh connection to your servers in a configurable way. However, it will not solve the "shell escape" problem that you might be suffering from