Posts: 3,616
Threads: 287
Joined: Jan 2003
Is it possible to get a return value from a DOS shell?
For instance:
SHELL "PING "+"255.255.255.255"
I want to test if the it went through, if it timed out, did I get a reply, etc.
Is there some kind of var=SHELL() function, that gets a return value from DOS?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 63
Threads: 10
Joined: Jan 2003
Hi zack, just do something like this:
Code:
INPUT "Enter IP address to ping: ", p$
file$ = "C:\PINGTEMP.TXT"
t$ = "PING " + p$ + ">C:\PINGTEMP.TXT"
SHELL t$
OPEN file$ FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, pingfile$
PRINT pingfile$
WEND
CLOSE #1
KILL file$
END
Don't forget the <space> after the word "PING " in the
t$ = "PING " line. Also, at the
Enter IP address . . . input, simply type the desired IP address, ie., 255.255.255.255, then hit enter.
And, do whatever you want with the pingfile$, you don't have to print it.
Dex
EDIT: And, so you know, you're simply redirecting the output of a command to a file, then reading that file.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Ah, good.
Didn't know that you could use PING to redirect results into a file
Heh, it would be a nice, but *hard*, project to write your own pinger.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 44
Threads: 5
Joined: Jan 2003
http://www.angelfire.com/tx5/someone42/
Sorry for the bad page design.
Look at "WSOCKXS 1.0", one of the examples is a pinger.