On 21/05/2014 17:02, Reinier Olislagers wrote: > On 21/05/2014 16:36, Peter Brooks wrote: >> Unfortunately, I've tried both the full path and just the name - >> apparently TProcess is supposed to look in the path - and it does >> work. When it is called, it returns a '0' indicating successful >> completion. > > /disclaimer: haven't looked at your code/ > voicechecker & fpcup contains a wrapper around TProcess[1] that lets you > easily get output. See the convenience functions ExecuteCommand etc. > > An example of use: pinging a host on OSX, can be found in voicechecker's > pingtest.pas [2] > > It works well for voicechecker, fpcup and some other projects > > [1] > https://bitbucket.org/reiniero/voicechecker/src/01d4337c5ed948aeafe57d892d33db98c0a9f742/processutils.pas?at=default > > [2] > https://bitbucket.org/reiniero/voicechecker/src/01d4337c5ed948aeafe57d892d33db98c0a9f742/pingtest.pas?at=default >
Perhaps you need to further analyze the output when you get result code 0 as the ping command may have succeeded but the hosts were unreachable. Voicechecker's voicecheckermain.pas uses this when calling pingtest: function TForm1.AnalyzeUnixPing(OutputText: TStringList): boolean; begin result:=false; if (pos(' 0.0% packet loss',OutputText.Text)>0) then //OSX result:=true else if (pos(' 0% packet loss',OutputText.Text)>0) then //Linux result:=true; end; and ATest:=TRemoteCommandTest.Create; ATest.TestName:='RouterInternetUp'; ... details ... TRemoteCommandTest(ATest).Command:='ping -c 1 www.google.com; echo ""; echo ""'; TRemoteCommandTest(ATest).AnalyzeOutput:=@AnalyzeUnixPing; ... more code... _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal