Executing multiple ssh commands inside a shell simultaneously
I would like to execute a commands in four different servers through ssh at a single instance(simultaneously).
Below are the details with examples,
Each statement will take some time to complete, and if i give like the above inside an shell, only when ssh at server1 is complete it will move to the next ssh.
For and while loop also takes one by one, only when one ssh is done, it picks the next ssh.
But, i would like to execute these three ssh commands at the same instance inside the shell and wait till all the three ssh gets completed and come out of the shell.
How about:-
This should fire them off and wait for all you background processes to finish before returning control. You can then read the log files to see what you got.
Be careful, as it will wait for all background processes, so if you were to set up a quick check from the same session and did a
... and then ran your script, it would wait until your tail had completed.
The above logic of moving the ssh commands to back end works fine in case of executing single command , but i'm facing issue when doing multiple commands like below.
If i try executing the above code, i'm getting the below errors.
This seems to work, but still facing some issues..
1. Not able to access the variables from the main script within the EOF tags
2. When using redirection operation within the EOF tags, i'm facing error with the file or folder doesn't exists.
When i tried the redirection operation with simple ssh, still its not working. Can you advise how we can use the file redirection operation within EOF tags.
Hi
Am having file.ksh as below
wc -l file1.txt
wc -l file2.txt
wc -l file3.txt
wc -l file4.txt
i want all the commands in this file to execute in same time
please help
Thanks in advance (1 Reply)
Hi,
I'm tryin to write a script that will collect information about a remote servers, put them into variables and print them to screen.
# /usr/bin/bash
ls $1 > /dev/null 2>/dev/null
if
then
echo "$1 is file"
for server in $(cat $1)
do
# echo $server
... (5 Replies)
I have some commands which need to be executed in remote machine.
I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Hi,
I work on a jumpserver and I wrote a script to transfer a file from source server to destination server.
#!/bin/ksh
echo "\nEnter the file name:\n"
read name
echo "\nSelect the Source server\n"
echo "1. ODS PROD "
echo "2. ODS DROPBOX"
echo "3. ODS STE"
echo "4. ODS STE DROPBOX"... (6 Replies)
Hi SSHers,
I have embedded this below code in my shell script..
/usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5`
SSH to both these servers are public-key authenticated, so things run... (13 Replies)
the ssh calling convention:
ssh <server>
If I put commands in the section, ssh will execute them immediately after logging in and return to local shell. I want to stay in the remote shell after executing these commands. How can I achieve this?
Thanks for all. (1 Reply)
Hi
I am trying to send a command over ssh with a parameter but the shell fails to expand the command properly any ideas what am i doing wrong with this.
This is ssh on AIX
for i in 71 72 73 74 75 do
for server in server1 server2 do
somestr="Some String"
echo "$server... (3 Replies)
The thing that we need to be able to do is:
- Scanning tapes from failed backup jobs with bscan (a bacula command)
- loading the next tape with the mtx command
Bscan does unload tapes but does not load them.
Bscan comes with this message when it's done with a tape:
Mount Volume... (0 Replies)
hi,
As you know, in Windows Programming, in WinMain method you will give n argument which you can know if this is another instance of the application or just the fresh execution.
How this functionality can be achieved in Linux application? Most of suggestions i have seen here in threads are... (5 Replies)
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell.
So scenario is that
- I need to have one shell script which is ran as a part of crontab
- in this shell script I need to do a... (2 Replies)