Simple CL

785 pts.
Tags:
AS/400


Hi friends, Wy this simple CL not works ?

 

 

PGM

DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)

 

LOOP: PING RMTSYS('XXX.XX.3.7')

RCVMSG MSGID(&MSGID)

 

 

IF COND(&MSGID *EQ 'TCP3206') THEN(GOTO +

CMDLBL(SEND))

SEND: SNDDST TYPE(*LMSG) TOINTNET((*NONE) +

(myname@mysite.com)) DSTD('remote host +

system did not respond') LONGMSG('bla bla +

bla address XXX.XX.3.7 off-line') +

SUBJECT('not connected')

GOTO CMDLBL(LOOP)

 

 

OK:

SNDPGMMSG MSG('PING SUCCEEDED!') TOPGMQ(*PRV)

ENDPGM

 

Thanks for all.





Software/Hardware used:
as/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

IF COND(&MSGID *EQ ‘TCP3206′) THEN(GOTO CMDLBL(SEND))
GOTO OK
SEND:
SNDDST TYPE(*LMSG) TOINTNET((*NONE)

I think you want a goto OK just before the SEND:
Phil

Thanks, Phil but not works, I´m receiving a message TCP3204 on this condition

IF COND(&MSGID *EQ ‘TCP3206′) THEN(GOTO CMDLBL(SEND)) and the job ends

Message ID . . . . . . . . . : TCP3204
Message file . . . . . . . . : QTCPMSG
Library . . . . . . . . . : QSYS

Message . . . . : Verifying connection to host system &2.

–> The TCP3204 is the first message received:

Verifying connection to host system xxx.xxx.3.7. = TCP3204
No response from host within 1 seconds for connection verification 1. = TCP3206
No response from host within 1 seconds for connection verification 2. = TCP3206
No response from host within 1 seconds for connection verification 3. = TCP3206
No response from host within 1 seconds for connection verification 4. = TCP3206
No response from host within 1 seconds for connection verification 5.= TCP3206
Connection verification statistics: 0 of 5 successful (0 %). = TCP3210

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • JohnN
    In your CL you need to test for both TCP3204 and the TCP3206 message When you get the TCP3204 you need to loop back to get the next message. Keep looping until the rRCVMSG return a blank message ID VFYTCPCNN RMTSYS(&CMPID) MSGLOOP: RCVMSG MSGTYPE(*ANY) MSGID(&MONMSGID) IF COND(&MONMSGID *EQ ' ') THEN(GOTO + CMDLBL(ENDLOOP)) GOTO MSGLOOP ENDLOOP:
    50 pointsBadges:
    report
  • Sloopy
    This is the sort of thing you need. Add the declares: DCL VAR(&MDATA) TYPE(*CHAR) LEN(12) DCL VAR(&PCENT) TYPE(*CHAR) LEN(4) VALUE(X'00000000') Then replace your RCVMSG and IF statements with this: RCVMSG MSGTYPE(*COMP) MSGDTA(&MDATA) MSGID(&MSGID) IF COND((&MSGID *EQ 'TCP3210') *AND + (%SST(&MDATA 9 4) *NE &PCENT)) THEN(GOTO + CMDLBL(OK)) Why? Because the PING command sends several messages. The only one you need is the last one, which is a COMPLETION message that says how many times the ping tried, and the percentage of times it succeeded. The RCVMSG is now only looking for this *COMP message. The IF statement now checks that the message is the right one, and then gets positions 9 - 12 of the message data returned in the RCVMSG command. This is the percentage successful. Since it's a 4-byte binary value we use a 4-byte field set to hex zero to check against it. If they match, then none of the ping passes was successful. But we are checking on NO match (to the message ID and to the number successful), so on NO MATCH we go to OK. Otherwise, the ping failed and we send the fail message. btw, you potentially can receive an awful lot of emails from the code as it is! Sloopy
    2,195 pointsBadges:
    report
  • TomLiotta
    Also, be very aware that ping does not tell you if a "connection" does or doesn't exist. Ping can only tell you if it succeeded or failed in getting a response. It's technically possible, though very unlikely, to have a ping succeed while other connections fail. It's much more likely to have pings fail while other connections work. Firewalls often block pings explicitly to avoid probes. A successful ping only tells if an active route exists to the destination. An active route may exist even if ping fails. Also, if you choose to ping by IP address, you should use the INTNETADR() parameter rather than the RMTSYS() parameter. The system will go through the process of DNS resolution for RMTSYS(). (This is usually minor. Problems might be rare, but they exist.) Finally, note that a failing ping might indicate a problem that also will cause SNDDST TOINTNET() to fail. Tom
    125,585 pointsBadges:
    report
  • PutzGrilla
    Yes, Tom and Sloopy About this obs "Finally, note that a failing ping might indicate a problem that also will cause SNDDST TOINTNET() to fail.". When the messages TCP3204, TCP3210, TCP3215 and TCP3211 occurs I receive too the snddst message. It´s complicated no ?, My Boss say to me .. "You cannot make a CL with 10 lines ?" I´m surviving...
    785 pointsBadges:
    report
  • Splat
    If you're only looking for one or two response messages (TCP3204, TCP3206) wouldn't it make more sense to use the MONMSG command to drive the SNDDST?
    6,995 pointsBadges:
    report
  • TomLiotta
    ...one or two response messages (TCP3204, TCP3206)... The MONMSG is a good enough idea, but the message to monitor for would be TCP3210. Specify MSGMODE(*N *ESCAPE). Instead of (*N), you can put the default (*VERBOSE) or the alternative (*QUIET). I'd probably leave (*N). Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following