1

I want to execute different commands on different servers. Server addresses are in a text file. Commands are the same except a parameter related to their addresses. For example: ./run0 on the first server, ./run1 on the next, and so on. As I want to execute different commands I do not think that pssh and other parallel ssh related commands be useful.

Thanks in advance.

Sorry, may be I did not explained completely. There is a file named "server_ips" that has 10 lines, each line specifies an IP address. what I need is to connect to these servers and execute a command in each of them say "./run'i'" which i is the line number of the address in the file. Also, I want to see the result of each execution. So, I want 10 terminals to be opened and connect to 10 servers and execute a command on the server.

  • Is there anything to identify the server? Or do the server names/ip's correlate to the command to be run in any way? Unless you have some correlation I can't immediately think of an easy way to achieve what you are trying. – sysadmiral Mar 5 '15 at 22:51
  • If you have a file containing server addresses separated by a new line then you could probably use something as: i=0; while read -r server; do printf '%s %s\n' "./run$((++i))" "$server"; done < server_addresses. I'm not sure what your final goal is, but this should "hopefully" give you a clue. – Valentin Bajrami Mar 5 '15 at 22:54
  • Thank you. But May be I did not explained correctly. There is file called server_ips that has 10 lines, each line specifies an IP address. what I need is to connect to these servers and execute a command in each of them say "./run'i'" which i is the line number of the address in the file. – masec Mar 6 '15 at 1:35
  • In the file, there are 10 ip addresses in each line. the command includes the line number, say ./run0 for the server which its ip address is in the first line and ./run5 for the server which its ip address is in the sixth line. – masec Mar 6 '15 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.