Page 1 of 3 123>
Topic Options
#73807 - 2003-02-28 04:40 PM The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
O.K. I tend to hate this, but here is goes.
Does anyone know the correct format of the following command to use in Win9x, and not NT/2k

c:\winnt\system32\cmd.exe /Q /E:1024 /C FOR /F "TOKENS=2* DELIMS= " %%i IN ('"PING -a -n 1 216.239.51.100 | FIND "]""') DO ECHO %%i >c:\report.txt
pause

This will work in a NT format, but get an invalid switch for Win9x.

Sad thing is that I cannot find out where that invalid witch is.

Any Clues????
_________________________
www.microcyb.com

Top
#73808 - 2003-02-28 04:45 PM Re: The correct format.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
well the first clue is that "c:\winnt\system32\cmd.exe" is NT specific. Should be %comspec%.

But then you probably are not using "c:\winnt\system32\cmd.exe" or else you would not be getting an "invalid switch" error.

I don't have any Wintendos to test on but my guess it the /Q switch. Spark up a DOS box and enter COMMAND /? to see the valid switches.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#73809 - 2003-02-28 04:53 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
LOL yes I know that c:\windows\command.com, and c:\winnt]system32\cmd.exe are the two different ones.
Thanks for pointing that out LLigetfa.

I do have %comspec% in the Kix script, and then pulling the result, to display the information.

Al that works, but here is the main issues I have.

SHELL '%Comspec% /Q /E:1024 /C FOR /F "TOKENS=2* DELIMS= " %%i IN ('+ CHR(39)
+ '"PING -a -n 1 $ipnum | FIND "]""' + CHR(39) + ') DO ECHO %%i >' + $tempfile

Only works in a NT/2K/XP enviorment.

DOS only tells me I have an inavlid switch on a WIN9X platform.

And for the life of me I cannot find that stupid invalid switch. [Mad]

In short I was just trying to ping two IP's
One is google.com, and the other is behind a vpn.

Wanted to know the results of the two so that I can know if the user is logged onto the ISP, and then the VPN.

Using Watlz function this is what I have:
code:
 ? REVPING("1.1.100.229")
? @error
? REVPING("216.239.51.100")
? @error
? "DONE"
get $

FUNCTION REVPING($ipnum)
DIM $nameip, $tempfile
$tempfile = "%temp%\nameip.txt"

SHELL '%Comspec% /Q /E:1024 /C FOR /F "TOKENS=2* DELIMS= " %%i IN ('+ CHR(39)
+ '"PING -a -n 1 $ipnum | FIND "]""' + CHR(39) + ') DO ECHO %%i >' + $tempfile

IF OPEN(10,$tempfile,2) = 0 $nameip = READLINE(10)
ELSE $nameip = ""
ENDIF
IF CLOSE(10) = 0
DEL $tempfile
ENDIF
IF $nameip <> "" $revping = TRIM($nameip)
EXIT (0)
ELSE $revping = "UNRESOLVED"
EXIT (1)
ENDIF
ENDFUNCTION

It works just right, but only on a NT platform. [Embarrassed]

So Hopefully some OLD SCHOOL people can tell me what the hell is the invalid switch. [Big Grin]
_________________________
www.microcyb.com

Top
#73810 - 2003-02-28 04:54 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
forget it ...
I wrote it too (see ping() udf) and didn't found anything but that FOR isn't available in 9x [Roll Eyes]
_________________________



Top
#73811 - 2003-02-28 04:56 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hmmm ... looking at the code tells me that I did actually wrote that line [Big Grin]

If you look a bit deeper you will find ping() udf which Waltz took and adapted to return names from ip ...

At least I mentioned in REQUIREMENTS the supported OS's [Wink]
_________________________



Top
#73812 - 2003-02-28 05:05 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Ahh O.K. jpols is de man to ask!
Your Ping() function also for a NT platform. it does in fact work perfect, and I do not reallt care about the DNS hostname conversion.

Here is the challenege for the day.
Can you, or is it possible to ping the followng IP's in a WIN9X platform:
VPN 1.1.100.229
PUBLIC 216.239.51.100
and just say true or false if it connected to the IP's or not?
_________________________
www.microcyb.com

Top
#73813 - 2003-02-28 05:06 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Think you have to go the hard way piping the output to a textfile open, read and do a little string manipulation ... or you might also want to try one of the pipe() udfs we got

hth
_________________________



Top
#73814 - 2003-02-28 05:09 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Or did you meant saying if the ping returns reply ?

That is actually possible ... or was it a fact that 'find' also denied to work on 9x ?
Can't remember anymore ... long time not used 9x for anything else than gaming [Big Grin]
_________________________



Top
#73815 - 2003-02-28 05:13 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Ahhhh Gaming gooood.... [Smile]

But just want to do like this in DOS
ping 216.239.51.100

but in KIX how can you do that?

In short I just wanted to know if you pinged an ip it could tell you yeah I can see it, or NOPE cannot see that ip, so that the rest of my script will continue or not.

So if the script or a function could just outpu true or false the the IP in the request.
_________________________
www.microcyb.com

Top
#73816 - 2003-02-28 05:15 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
my gaming platform is KiOSX, so need for win9x there either [Wink]
_________________________
!

download KiXnet

Top
#73817 - 2003-02-28 05:25 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure it can [Wink]

something like:
code:
shell '%comspec% /c ping $ip | find "0% loss" >null'
if @error
"could not ping"
else
"ping succesfull"
endif

_________________________
!

download KiXnet

Top
#73818 - 2003-02-28 05:26 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
So any ideas guys?
_________________________
www.microcyb.com

Top
#73819 - 2003-02-28 05:49 PM Re: The correct format.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
So, what exactly is your problem? You cannot SHELL out your PING and then check a resulting text file?

Lonkeros code doesn't work for you?

The PING() UDF doesn't work for you?

Could you please be precise?

[ 28. February 2003, 17:50: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#73820 - 2003-03-03 05:48 PM Re: The correct format.
JimRobinson Offline
Fresh Scripter

Registered: 2003-01-10
Posts: 42
Loc: Tempe, AZ
This may be a bit late, but FOR /F is not supported in 9x. I don't have any 9x boxes right at hand, so I can't be much more help than that on the shell side, but think you would probably be best off sending the output to file and parsing that in KiX.
_________________________
Jim
--------------------

Top
#73821 - 2003-03-03 08:15 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yep Jim,

think I mentioned that before [Razz] [Big Grin]

Hello Microcyb ???

You still around ?
_________________________



Top
#73822 - 2003-03-17 07:01 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Yep still around, and still no luck
_________________________
www.microcyb.com

Top
#73823 - 2003-03-17 07:11 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
microcyb, what did my code return?

please, could you help us help you?
_________________________
!

download KiXnet

Top
#73824 - 2003-03-17 07:39 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Well, not sure but every ping no matter if it is a bad ip or a good ip, says ping sucessfull.

so if I ran your script to ping 0.0.1.1 it says it pinged, and if you place in a good ip, it says the same result.
_________________________
www.microcyb.com

Top
#73825 - 2003-03-17 07:43 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, simple check to ping reply retrieved that the string was little wrong.
you will be perfectly server with:
code:
$ip="0.0.1.1"
shell '%comspec% /c ping $ip | find "(0% loss)" >null'
if @error
"could not ping"
else
"ping succesfull"
endif

_________________________
!

download KiXnet

Top
#73826 - 2003-03-17 08:49 PM Re: The correct format.
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Still says ping succesfull even for a bad ip address.
_________________________
www.microcyb.com

Top
Page 1 of 3 123>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.163 seconds in which 0.108 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org