Qbasicnews.com

Full Version: Return Value from DOS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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.
Ah, good.
Didn't know that you could use PING to redirect results into a file Tongue
Heh, it would be a nice, but *hard*, project to write your own pinger.
http://www.angelfire.com/tx5/someone42/

Sorry for the bad page design.

Look at "WSOCKXS 1.0", one of the examples is a pinger.