All good!

With the terminal is still on you, so I can not figure it out. There is a function that should take the server number from the loop:

function func() { ssh server@server$1.ru .... } for server in {01..03} do func $server done 

Persistently not read $ server

  • Linux has nothing to do with it, it is a question of the shell, most likely bash - andreymal
  • it seems to be all right .... what exactly does $ server not read? - Fat-Zer 4:05 pm
  • Give the example of your 1st line of the file we wish the result #!/bin/bash , #!/bin/sh , #!/usr/bin/env bash . Give an example of working out the script. - Hellseher
  • Add echo characters (at the end of the space) in front of the ssh characters and look at the result. - aleksandr barakin

1 answer 1

Pasted your code into the file, adding the echo call just before ssh :

 function func() { echo ssh server@server$1.ru .... } for server in {01..03} do func $server done 

and ran:

 $ bash файл ssh server@server01.ru .... ssh server@server02.ru .... ssh server@server03.ru .... 

The output indicates that the parameter reads perfectly.

so if your program behaves differently than you expect, then either you expect from it is not what it actually is, or the error is not in the place that you assumed (non-transmitted function parameter).


in general it looks like you need something like gnu / parallel . good of them a lot .

  • I did the same result, idiotic to yours, did not publish. The question is little data about what the author is doing. Surely not an exact script as a whole, based on the fact that the author is on you with bash. - Hellseher