Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Return Value from DOS
#1
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.
Reply
#2
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.
Reply
#3
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.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#4
http://www.angelfire.com/tx5/someone42/

Sorry for the bad page design.

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


Forum Jump:


Users browsing this thread: 1 Guest(s)