However, I cannot figure out how to call this from the program , i'm using OpenURL at the moment and it just doesn't work at all and I dont really know why. I need it to launch traceroute and then silently exit, does anyone have any ideas please?
A couple of ways:
system_("traceroute www.simtouringcarcup.com >mytrace.txt")But that will halt your program until the traceroute finishes.
Check out the pub.mod/freeprocess.mod , it allows you to launch a process while your program keeps running, which is probably better suited to what you want.
See below for a sample of how to use it... Unfortunately I don't remember who posted it to the forums recently, so apologies for the lack of attribution. :-?
You'll need some minor adjustments to run it on the Mac, but it will probably be a good start)
Framework BRL.Win32MaxGUI
Import BRL.Timer
Import PUB.FreeProcess
SuperStrict
Global wndMain:TGadget = CreateWindow("Test Window",100,100,400,300,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_STATUS)
Global gadButton:TGadget = CreateButton("Start",10,10,100,25,wndMain,BUTTON_PUSH)
Global pcsNotepad:TProcess
CreateTimer(2) 'Create a timer that allows us to check status of process every 500ms
Repeat
Select WaitEvent()
Case EVENT_WINDOWCLOSE;TProcess.TerminateAll();End 'If the program is closed, terminate all running processes.
Case EVENT_GADGETACTION
Select EventSource()
Case gadButton;If GadgetText$(gadButton) = "Start" Then StartNotepad() Else CloseNotepad()
EndSelect
Case EVENT_TIMERTICK
If pcsNotepad <> Null Then SetStatusText(wndMain,"Status of Notepad Process: " + pcsNotepad.Status()) Else SetStatusText(wndMain,"Object doesn't yet exist.")
If pcsNotepad <> Null And pcsNotepad.Status() = 0 Then SetGadgetText(gadButton,"Start") 'If notepad was closed by user outside the program, update button text.
EndSelect
Forever
Function StartNotepad()
If pcsNotepad <> Null Then pcsNotepad.Terminate() 'Terminate process if it a) exists b) is running.
pcsNotepad = CreateProcess("notepad.exe") 'Open the process notepad.exe and store handle in pcsNotepad
SetGadgetText(gadButton,"Stop") 'Change button text.
EndFunction
Function CloseNotepad()
If pcsNotepad <> Null And pcsNotepad.Status() Then pcsNotepad.Terminate() 'Terminate process if it a) exists b) is running.
SetGadgetText(gadButton,"Start") 'Change button text.
EndFunction
traceroute www.simtouringcarcup.com >myTrace.txt
One downside is that this is an external utility, which may or may not exist, and the current user may or may not have permissions to use the binary if it does exist... Which means you may also need to distribute one along with your program to make sure it 'always' works.
Unfortunately ping (and traceroute, which is nothing but a series of pings with a specified max number of hops, as explained by Pantheon above) uses a specifically crafted type of datapacket which BlitzMax natively does not provide.
Perhaps a good feature request -- some basic PING commands?