Output to file from System()

Hi,

I have the following command:
system("start \"\" \"C:\\Program Files\\Wireshark\\tshark.exe\" -a duration:130 -i 3 -T fields -e frame.number -e frame.time -e _ws.col.Info > c:\\test\\myfile.csv");

The aim of the command is to start tshark and have it listen, in the background, for a set time. For that purpose, the command works fine. My issue is that the output ">" is ignored, it only writes to console, not file.

If I don't spawn it to a new window the output is written to the target file without issue. Can anyone correct the command so that it writes to file and runs in the background?

I'm new to c++ and this has been driving me nuts...
Last edited on
I'm new to c++ and this has been driving me nuts...


This doesn't have anything to do with C++.

It looks like you're redirecting the output of start to the file.

Try:
system("start \"\" \"C:\\Program Files\\Wireshark\\tshark.exe > c:/test/myfile.csv\" -a duration:130 -i 3 -T fields -e frame.number -e frame.time -e _ws.col.Info");

Note that windows handles forward slashes correctly.

A little further research shows that you just need to escape the '>' so it's passed on:

system("start \"\" \"C:\\Program Files\\Wireshark\\tshark.exe\" -a duration:130 -i 3 -T fields -e frame.number -e frame.time -e _ws.col.Info ^> c:\\test\\myfile.csv");



Last edited on
Thanks for replying!

I tried the escape solution and the window only briefly appears before closing again. No output file gets created or written to...
Topic archived. No new replies allowed.