Page 2 of 3 <123>
Topic Options
#73827 - 2003-03-17 08:51 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
could you please tell what ping returns in win9x.

that code above works just fine on NT-based machines.
_________________________
!

download KiXnet

Top
#73828 - 2003-03-17 08:57 PM Re: The correct format.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Works for me. Mind you, I don't have Wintendo to test on. Maybe should post back the code you are trying in case you are modifying Jooels.

[ 17. March 2003, 20:58: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#73829 - 2003-03-17 09:58 PM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Me, Awaiting Reply, Chief of Nutshell tribe says "TTL=" is only way white man gets right answer, Hugh !
_________________________



Top
#73830 - 2003-03-17 10:44 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I was waiting for that comment jochen.
I don't like the ttl way and that's it.
_________________________
!

download KiXnet

Top
#73831 - 2003-03-17 11:13 PM Re: The correct format.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well there's already a gazillion examples posted using "TTL"...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#73832 - 2003-03-17 11:47 PM Re: The correct format.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Ugh... #$%@^

Can't believe author of PostPrep don't use for his own code posting either.

Very easy to setup a link/shortcut to run it Jooel [Eek!]

I'm getting lazy. Even short code is much easier to copy from board when PostPrep is used.

Now where did I hide that Write/MS Word application? [Razz]

Top
#73833 - 2003-03-18 01:19 AM Re: The correct format.
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
This works on XP and 98...

code:
 
$junkfile = "%temp%\winscl.xxx"
del $junkfile

shell '%comspec% /c ping -n 2 216.239.33.100 > $junkfile'
$filehandle = FreeFileHandle ( )
If Open ($filehandle, $junkfile) = 0
$line = ReadLine ($filehandle)
While @Error = 0
If InStr ($line, "Reply from")
$replies = 1
Endif
$line = ReadLine ($filehandle)
Loop
Endif
$null = Close ($filehandle)
del $junkfile

If $replies < 1
? "Server not responding at this time"
Else
? "The server is up"
Endif

get $


Top
#73834 - 2003-03-18 01:28 AM Re: The correct format.
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Tried your snippet as well Lonkero. I also get ping successful on every address in win98, even though the "(0% loss)" should work...

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



[ 18. March 2003, 01:31: Message edited by: CitrixMan ]

Top
#73835 - 2003-03-18 07:50 AM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, now we are helping a boy that seems not to wont that help.
shane, could you check on commandline what the find returns on win9x?
if it works as expected, do after it:
echo %errorlevel%

to see does win9x find return errorcode.
if it does, then command.com does not.
_________________________
!

download KiXnet

Top
#73836 - 2003-03-18 10:33 AM Re: The correct format.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Lonkero,

Windows 95 does not have the 0% loss on my test system.

If you do this, it does find it, but apparently does not set an errorlevel when I echo %errorlevel% to the console it is blank.
If you give it something real to find it will display on console what it found, but if you give it something bogus to find it remains blank on console.



shell '%comspec% /c ping $ip | find "Request timed out" >null'



That's why you always get a SUCCESSFUL answer as the errorlevel is never set on Windows 95

Top
#73837 - 2003-03-18 10:32 PM Re: The correct format.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
thanks for the answer.
_________________________
!

download KiXnet

Top
#73838 - 2003-03-18 11:36 PM Re: The correct format.
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Yea...What NTDoc said... [Wink]
Top
#73839 - 2003-03-19 09:29 AM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

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

if noone likes 'TLL=' I explain it more to the point and hopefully everyone will agree that it is the only way :

So, assuming you run Windows NT Workstation, how would you ever get a valid response in finding '0% loss' (there is never ever such a phrase on Console !)

sample :

quote:
C:\WINNT\system32>ping 10.128.12.20

Pinging 10.128.12.20 with 32 bytes of data:

Reply from 10.128.12.20: bytes=32 time=10ms TTL=125
Reply from 10.128.12.20: bytes=32 time<10ms TTL=125
Reply from 10.128.12.20: bytes=32 time<10ms TTL=125
Reply from 10.128.12.20: bytes=32 time<10ms TTL=125

C:\WINNT\system32>

(Have you noticed that there is "TTL=" in every reply ???)

Good, and now for guys trying to search for "TTL" which CAN also result in erroneous response !

Here is the CAN case :

quote:
C:\WINNT\system32>ping 10.134.126.20

Pinging 10.134.126.20 with 32 bytes of data:

Reply from 10.63.4.133: TTL expired in transit.
Reply from 10.63.4.133: TTL expired in transit.
Reply from 10.63.4.133: TTL expired in transit.
Reply from 10.63.4.133: TTL expired in transit.

As you might see there is in fact a TTL to be found but that doesn't mean that you get reply from the machine you pinged !

so 'TTL=' is it (for any MS OS you can imagine !)

[Mad]

{edit}Oh yeah ! 'Request timed out' is also nonsense :

quote:
C:\WINNT\system32>ping xyz
Bad IP address xyz.

would return 'reply' [Roll Eyes]
{/edit}

[ 19. March 2003, 09:32: Message edited by: jpols ]
_________________________



Top
#73840 - 2003-03-19 09:49 AM Re: The correct format.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Jochen... dude, you need to fire up a Windows 95 client and try a ping to a valid address that is not responding.

You will see: Request timed out

in the result on the console. I said nothing about NT/2000/XP this test is ONLY for Windows 95

I might assume that 98 responds the same, not sure about ME as it did add some minor new stuff that 2000 has.

Top
#73841 - 2003-03-19 09:54 AM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sorry , I have none ...

Ok, still valid is that from at least NT 3.x upwards there is no other way than finding "TTL=" for reply from pinged machine.
But Ron, don't you accept that 'request timed out' is out of the loop (if one likes to provide a global valid solution) as for the possible 'BAd Ip Address' one always can have due to resolution problems, especially with WINS ?

[Razz] [Razz] [Razz]

Anyway, if my little time allows I will test this evening from my daughters ME installation

[ 19. March 2003, 09:57: Message edited by: jpols ]
_________________________



Top
#73842 - 2003-03-19 10:37 AM Re: The correct format.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
hmmm... not sure you can have a GLOBAL 1 size fits all piece of code here. The returned text on Windows 95 is not the same as NT/2000/XP

I also think that ME does show similar to 2000

The start of this topic was about the guy wanting to get a response from Win9x. We all know NT/2000/XP works just fine. Not that big of a deal, more a request to get an antique OS to return a value to test against.

Top
#73843 - 2003-03-19 10:47 AM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
So , the only question left is :

does this work on a Windows 95 Computer ?



break on

$Computer = "" ; Place here any valid (and online) Computer/IP-Address

shell '%Comspec% /C ping $Computer | find /C "TTL=" > nul'

if @error = 0
    $Computer + " replied to the ping request!" ?
else
    $Computer + " was reported OFFLINE, please verify on console!" ?
endif

get $



agreed ?
_________________________



Top
#73844 - 2003-03-19 11:08 AM Re: The correct format.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Jochen,

Here is what you get from a Windows 95 workstation.
Notice that a valid ping first, then run script... Looks okay.
Then ping an address that times out, ping shows REQUEST TIMED OUT
Then run script... Still says it replied to the ping request even though it DID NOT.
That is because @error is not being set. i.e. There is no %errorlevel% set on
Windows 95, thus this method can not be used.

C:\SCRIPTS>ping 192.168.1.101

Pinging 192.168.1.101 with 32 bytes of data:

Reply from 192.168.1.101: bytes=32 time=1ms TTL=128
Reply from 192.168.1.101: bytes=32 time=1ms TTL=128
Reply from 192.168.1.101: bytes=32 time=1ms TTL=128
Reply from 192.168.1.101: bytes=32 time=1ms TTL=128

C:\SCRIPTS>kix32 9x2.kix
192.168.1.101 replied to the ping request!

C:\SCRIPTS>ping 139.104.117.95

Pinging 139.104.117.95 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

C:\SCRIPTS>kix32 9x2.kix
139.104.117.95 replied to the ping request!

Top
#73845 - 2003-03-19 11:13 AM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ouch !

Ok ... then there is no valid method for 95 (except maybe some fancy wsh methods [Roll Eyes] ) as it'd also fail on 'request timed out' (if i got that correctly it does not set errorlevel in any case) [Frown]

So Microcyb ...

TASK = Declare all networked 9x machines as Gameboys (Be a man, accept the facts !) [Big Grin]
_________________________



Top
#73846 - 2003-03-19 11:17 AM Re: The correct format.
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hey !

Not to forget that my statement about "TTL=" is still valid for all (MS) NON-9x OS [Wink]

Quod Erat Demonstrandum !
_________________________



Top
Page 2 of 3 <123>


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

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.075 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

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