1

I want to use a script in Linux to start multiple instances of iperf3 as server like this:

gnome-terminal -e --bash -c "iperf3 -s -B 10.10.1.1 -p 5021"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.2.1 -p 5022"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.3.1 -p 5023"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.4.1 -p 5024"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.5.1 -p 5025"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.6.1 -p 5026"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.7.1 -p 5027"
gnome-terminal -e --bash -c "iperf3 -s -B 10.10.8.1 -p 5028"

Its not working, whats the issue?

1 Answers1

1

I'm sure you did not want to pass --bash and -c as options to gnome-terminal. Probably you wanted to use bash -c … as a command to run in GNOME Terminal; but there is no point of bash -c when it's going to execute just a single command (iperf3 … in your case).

Your lines look like frankencode containing three ways of running a command:

  • bash -c 'shell code as a single string, therefore quoted here'
    
  • gnome-terminal -e 'executable with arguments as a single string'
    
  • gnome-terminal -- executable with arguments as separate words
    

The form with bash does not involve gnome-terminal (although it can be used with gnome-terminal, we will get to this). The form with -e is deprecated; the form with -- is recommended. The right syntax for you is simply:

gnome-terminal -- iperf3 -s -B 10.10.1.1 -p 5021

Rebuild your remaining lines accordingly.

If you want to run shell code, then you need sh -c, bash -c or so. Example:

gnome-terminal -- sh -c 'iperf3 -s -B 10.10.1.1 -p 5021; exec bash'

where ; belongs to shell syntax. In the above command gnome-terminal runs sh with arguments -c and iperf3 -s -B 10.10.1.1 -p 5021; exec bash. This sh runs iperf3 and waits for it to finish, then it replaces itself with interactive bash.