View previous topic :: View next topic
|
Author |
Message |
bhim_s
New User
Joined: 19 Sep 2006 Posts: 46 Location: Australia
|
|
|
|
Hi!!
i want to use the tso ping command in rexx to check whether the server is up or down. if it is UP then fine else it should go in sleep mode for 10 seconds and then again check the server is up or down. process will go four times in the loop till the sever is not up. After the loop it will display the final msg if it is UP or DOWN.
My plan was to capture the return code from the ping command to check the server and work accordingly but every time it is returning a rc = 0
Below my code :
Code: |
/*REXX*/
trace I
say 'Enter host name or address'
pull addr
PING addr
say "rc" rc
do digit=1 to 4
if RC = 4 then
do
say 'server is not up trying to reconnect...'
PING addr
SAY 'RETURN CODE' RC
end
else
do
say 'server is up'
SAY 'RETURN CODE' RC
exit RC
end
end
trace n
exit RC |
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
I can barely spell REXX, but where is the "sleep" and what is the "exit RC"? |
|
Back to top |
|
|
bhim_s
New User
Joined: 19 Sep 2006 Posts: 46 Location: Australia
|
|
|
|
i have not done the coding for sleep mode yet ... that i will do after checking the server. Exit rc -- i feel it will exit from execution and throw the return code of the last executed statement. please correct me if i am wrong |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Seems to me that it will exit the first time it gets executed...the first time the RC is not 4.....
Code: |
else
do
say 'server is up'
SAY 'RETURN CODE' RC
exit RC
end
end |
|
|
Back to top |
|
|
bhim_s
New User
Joined: 19 Sep 2006 Posts: 46 Location: Australia
|
|
|
|
Yes, when the code is executed every time it is throwing rc =0
Code: |
CS V1R7: Pinging host XXFTP.AAAA.COM (151.nnn.nnn.nnn)
Ping #1 response took 0.016 seconds.
7 *-* say "rc" rc
>L> "rc"
>V> "0"
>O> "rc 0"
rc 0 |
Even if i put the wrong IP. it returns 0.
This is what i have tried i am not sure if e'm on the right track.
Would be great if you can guide me ... how can i check the sever if it is up or down. |
|
Back to top |
|
|
bhim_s
New User
Joined: 19 Sep 2006 Posts: 46 Location: Australia
|
|
|
|
One more thing i come to know if I specify IP : 120.111.10.0 then it returns 4 if I specify IP:10.188.9.0 it returns 0 both are invalid IP for me. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It may be that the "ping" command executed "successfully" even though it could not find the named host (i've not ping'ed from the mainframe, so i don't know how it responds). This may also be true when the ping times out. You may need to look into looking at the response from the ping and then determining if the server was up.
I believe there are 3 conditions to look for:
1. invalid name or ip address
2. request timed out
3. request successful |
|
Back to top |
|
|
|