Powerful! output the result of system() directly

Find and share HowTos to various installations / configurations!
4 posts • Page 1 of 1
Chenghannong
Posts:1
Joined: Thu Feb 17, 2011 6:16 am

Powerful! output the result of system() directly

Post by Chenghannong »

string out;
out=system("ping pc1 -c 2|grep Reply");//linux
out=system("ping pc1 -n 2|grep Reply");//windows
out=system("netstat -a -n -o");
Debug(out);

it is available in v3.8/3.9/3.10 in windows/linux although online help is "int ret=system();"

zs9782
Posts:2
Joined: Sat Oct 09, 2010 9:37 am

Re: Powerful! output the result of system() directly

Post by zs9782 »

This author is as PVSS expert in Siemens Ltd.,China, please give him a ebullience support.

zs9782
Posts:2
Joined: Sat Oct 09, 2010 9:37 am

Re: Powerful! output the result of system() directly

Post by zs9782 »

Very good function, this solution was come from Si Chuan Longgang gas field SCADA project in China.

aorange
Posts:147
Joined: Thu Nov 04, 2010 10:07 am

Re: Powerful! output the result of system() directly

Post by aorange »

The helpfile states:
Returns the return code of the program that was executed. Returns -1 if no argument was specified, a new process could not be created or if the started process was not finished normally.
For the purpose of debugging I would simply call the system() function from within the DebugN() function ;)

Code: Select all

DebugN( system( "tracert 127.0.0.1" ) );

4 posts • Page 1 of 1