Qbasicnews.com
July 25, 2021, 12:01:32 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Return Value from DOS  (Read 2154 times)
Zack
*/-\*
*****
Posts: 3974



WWW
« on: March 13, 2003, 10:42:30 AM »

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?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Dex4now
Member
*
Posts: 75


WWW
« Reply #1 on: March 13, 2003, 06:24:22 PM »

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.
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #2 on: March 13, 2003, 11:34:25 PM »

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.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
someone42
Member
*
Posts: 44


« Reply #3 on: March 16, 2003, 02:04:22 AM »

http://www.angelfire.com/tx5/someone42/

Sorry for the bad page design.

Look at "WSOCKXS 1.0", one of the examples is a pinger.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!