Search code examples
pythonperlcommand-linecommand-line-argumentsiperf

How do I pipe to a text file the command prompt output from iperf to a file


I am trying to start an iPerf server (its a program similar to ping), and pipe its output to a .txt file.

On another PC, the client is sending traffic to this IP address.

Here is the command :

start "LocalFLServer" iperf -s -w 1024k -i 2 -B 10.42.113.120 -p5003

I want to pipe its output to a txt file, so I tried both

start "LocalFLServer" iperf -s -w 1024k -i 2 -B 10.42.113.120 -p5003 -o dl_tcp.txt

and

start "LocalFLServer" iperf -s -w 1024k -i 2 -B 10.42.113.120 -p5003 > dl_tcp.txt

But both instructions are not able to pipe the results to a .txt file.

The problem here is because I am starting this server on a separate command prompt using the 'start' command. I know it will write a .txt file if I remove the 'start'., but unfortunately, in the Perl script soon after I send this command using system(), I need to run another instruction, or the program will not proceed further and would remain stuck which I dont want.

Help.

Edit : In Perl, I add/send the instruction like this :

system(start "LocalFLServer" iperf -s -w 1024k -i 2 -B 10.42.113.120 -p5003 -o dl_tcp.txt)

Solution

  • I'm not 100% sure, but I think there might be an issue with iperf's logging to file feature. From this link: https://code.google.com/p/iperf/issues/detail?id=24 , it appears it was an unresolved issue up till atleast Dec 23, 2013.

    I also took a look at iperf's source code, and in this file : https://github.com/esnet/iperf/blob/master/src/main.c , the arguments are passed to the function "iperf_parse_arguments" which is located in the file: https://github.com/esnet/iperf/blob/master/src/iperf_api.c , and when I look at the method, I do not see anything which handles "-o" or "--output".

    I am not sure why using the ">" is not working.