Computing.Net > Forums > OS/2 > Ping with Rexx

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Ping with Rexx

Reply to Message Icon

Name: Andy B
Date: December 1, 1999 at 04:56:59 Pacific
Comment:

I want to ping a bunch of machines in my Intranet using a Rexx script. To my dismay, using the function FTPping from RXFTP.DLL does not work reliably. Any other suggestions? I'd really hate to have to send a ping to cmd and have to parse the output (unless someone already has proven code to do that.).

Thanks, Andy



Sponsored Link
Ads by Google

Response Number 1
Name: voytek
Date: December 2, 1999 at 05:44:26 Pacific
Reply:

I use following CMDs to do some stuff, if that helps. yo're welcome:

/* Voytek's Pinger */
/*
this application uses a ping function with the following specs:

ping
Usage: ping [-?drv] [size [packets]]

the expected output includes the following:

----xxx.yyy.zzz.qqq PING Statistics----
10 packets transmitted, 10 packets received, 0% packet loss
round-trip (ms) min/avg/max = 30/31/40

we search for these lines, and parse their results

The external command must return 4 lines of output:
Line 1 : current state of the 'incoming bytes counter'
Line 2 : current state of the 'outgoing bytes counter'
Line 3 : string, telling the uptime of the target.
Line 4 : string, telling the name of the target.
*/

SIGNAL On Halt

Server= stdout('hostname') 'Ping'
Uptime=STRIP(SUBSTR(stdout('go -ut'),71))

PARSE ARG Target /* Include host, size & count of pkts */

Newq=Rxqueue('Create')
'@ ping 'Target'|rxqueue'


DO While Queued() >< 0
PULL Line
IF Pos('TRANSMITTED',Line)>< 0
Then
DO
Rline = Reverse(Line)
PARSE Var Rline . . '%' Rlost .
Lost = Reverse(Rlost)
/* SAY Lost */
End /* do */
/* IF Pos('ROUND',Line)>< 0
Then
DO
Rline=Reverse(Line)
PARSE Var Rline Rmaxi '/' Ravg '/' Rmini .
Maxi=Reverse(Rmaxi) ; Avg=Reverse(Ravg) ; Mini=Reverse(Rmini)
/* SAY Maxi
SAY Mini
SAY " " */
SAY Avg
End
*/ /* do */
End

SAY Lost
SAY '0'
SAY uptime /* do */
SAY server STRIP(Target) lost '% lost packets'
HALT:
CALL Rxqueue 'Delete',Newq
EXIT


and

/* Voytek's Pinger */
SIGNAL On Halt

Server= stdout('hostname') 'Ping'
Uptime=STRIP(SUBSTR(stdout('go -ut'),71))

PARSE ARG Target /* Include host, size & count of pkts */

Newq=Rxqueue('Create')
'@ ping 'Target'|rxqueue'

DO While Queued() >< 0
PULL Line
/* do */
IF Pos('ROUND',Line)>< 0
Then
DO
Rline=Reverse(Line)
PARSE Var Rline Rmaxi '/' Ravg '/' Rmini .
Maxi=Reverse(Rmaxi) ; Avg=Reverse(Ravg) ; Mini=Reverse(Rmini)
SAY Maxi
SAY Mini
SAY uptime
/* SAY Avg */
End /* do */
End /* do */
SAY SERVER STRIP(Target) 'round-trip (ms) min/avg/max =' mini'/'avg'/'maxi
HALT:
CALL Rxqueue 'Delete',Newq
EXIT


0

Response Number 2
Name: Andy B
Date: December 2, 1999 at 06:08:19 Pacific
Reply:

Look excellent! I'll get around to testing and expanding it for my purposes in the next few days.
Thanks a lot.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to OS/2 Forum Home


Sponsored links

Ads by Google


Results for: Ping with Rexx

os/2 vs. dos www.computing.net/answers/os2/os2-vs-dos/290.html

ecs / warp4 / warp 3 differences? www.computing.net/answers/os2/ecs-warp4-warp-3-differences/1100.html

LAN Requester not working www.computing.net/answers/os2/lan-requester-not-working/1486.html