Home>

The net performance measurement command (iperf3) is executed using subprocess.Popen in python3.
Popen, iperf3 itself can be executed without problems, but by using iperf3's -T (title) option
Stumbling.

The code that was tried, the result output, and the expected output are shown below.

>>>import subprocess
>>>import sys
>>>from time import sleep
>>>
>>>round_id = 1
>>>while True:
... a = subprocess.Popen ("iperf3 -c bouygues.iperf.fr -t 5 -T` date +% F_% T`.TCPround = $round_id ", shell = True)
... sleep (30.0)
... round_id + = 1
...

Result:

2018-08-29_17: 13: 03.TCPround =: Connecting to host bouygues.iperf.fr, port 5201
2018-08-29_17: 13: 03.TCPround =: [7] local 192.168.225.20 port 51698 connected to 89.84.1.222 port 5201
Omitted on the way
2018-08-29_17: 13: 03.TCPround =: iperf Done.
2018-08-29_17: 13: 33.TCPround =: Connecting to host bouygues.iperf.fr, port 5201
2018-08-29_17: 13: 33.TCPround =: [7] local 192.168.225.20 port 51735 connected to 89.84.1.222 port 5201
Omitted on the way
2018-08-29_17: 13: 33.TCPround =: iperf Done.

Expected output:

2018-08-29_17: 13: 03.TCPround = 1: Connecting to host bouygues.iperf.fr, port 5201
2018-08-29_17: 13: 03.TCPround = 1: [7] local 192.168.225.20 port 51698 connected to 89.84.1.222 port 5201
   Omission
2018-08-29_17: 13: 03.TCPround = 1: iperf Done.
2018-08-29_17: 13: 33.TCPround = 2: Connecting to host bouygues.iperf.fr, port 5201
2018-08-29_17: 13: 33.TCPround = 2: [7] local 192.168.225.20 port 51735 connected to 89.84.1.222 port 5201
Omitted on the way
2018-08-29_17: 13: 33.TCPround = 2: iperf Done.

Of the strings I want to pass to iperf3's -T option, the date and time has passed without any problem and is displayed as the title of the iperf3 output line, but the round_id is not displayed. Please tell us how to solve the problem, not a problem specific to iperf3, but a problem with how to pass parameters in Python3.