<?php
$cmd = "C:\WINDOWS\system32\ping.exe ping 10.16.2.102 -n 1 && exit";
exec($cmd, $output);
print_r($output);
?>
If you use the Process object from the Threading library you can wait until the command finishes which makes things easier. P is a Process object. Note that all the filenames are explicitly prefixed by AppPath to make sure that files are where you expect them. I had trouble if I left them out - you may or may not experience the same.You can create a small batch file with the command:
ping 192.x.x.x > 1.txt Then run the batch file with Shell. The output will be saved to 1.txt.
P.New1
FileOpen(f, AppPath & "\doit.bat", cWrite,, cASCII)
cmd = "ping 127.0.0.1 > " & AppPath & "\ping.txt"
FileWrite(f,cmd )
FileClose(f)
P.Start(AppPath & "\doit.bat", "")
P.WaitForExit(-1)
FileOpen(f, AppPath & "\ping.txt", cRead)
t = FileReadToEnd(f)
FileClose(f)
Msgbox(t)
Good point Erel! I'm old-fashioned and don't put spaces in my file and folder names - somehow it just doesn't seem right to do that. I've never really got over the demise of 8.3 filenames .It is better to wrap the path with quotes in case you have spaces in it: