how to get \"system ping and return value\"

Find and share HowTos to various installations / configurations!
3 posts • Page 1 of 1
gyu
Posts:11
Joined: Wed Mar 19, 2014 2:08 am

how to get \"system ping and return value\"

Post by gyu »

Using a WINCCOA 3.12 and windows server 2003.

I want to make a script like that getting the ping test and return value.

return value means, example " 172.10.50.3 ok"

i know, IEC61850 driver have a this function.

so, in driver, stats can have a value 0 to 3.

i need it like the function.

make sure ping test and get a ping is ok or not.

i did it as follow, but it return the value ok only.

Code: Select all

int main(){

	int i;

	char cmd[40];
    char ret;
    
	for(i=1; i

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: how to get \"system ping and return value\"

Post by fmulder »

In 3.14 the system() function has additional parameters where you can directly 'receive' the result of the command that you call. Unfortunately, you do not have this in 3.12

I'd say that you probably have to do :

Code: Select all

string strResult;
system( "ping 127.10.50.3 > c:/tmp/pingresult.txt" );
fileToString( "c:/tmp/pingresult..txt", strResult );
DebugN( strResult )
Sometimes I use :

Code: Select all

system( 'cmd /c ping 127.10.50.3 > c:/tmp/pingresult.txt" );
p.s. A short tip. When you open the panel of the Ascii manager (asciiman.pnl) and look for 'system()' then you'll find that this panel does the same thing. Please look in your 3.12 project
p.s. I did not test the above code

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: how to get \"system ping and return value\"

Post by Gertjan van Schijndel »

In control normally the type string is used instead of an character array. Also the debug functions are used to write a message to the log file instead of printf.

With these small changes the code works under 3.14.

3 posts • Page 1 of 1