How to get IP address of as400 machine in CL pgm

165 pts.
Tags:
API
AS/400 Management
CL
CL programs
Hi

CAn any 1 tell me how to get the IP address of the AS400 machine in CL program.Are there any API for this.I need  to pass this IP to run a java program thrugh CL..

Thankx in advance

Supriyob

 



Software/Hardware used:
AS400
ASKED: September 1, 2009  11:00 AM
UPDATED: October 22, 2009  1:34 AM

Answer Wiki

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

I got this src from a website a long time ago. Have used it a couple of times – Thanks to the author who I forget
<pre>
/* =============================================================== */
/* = Program……. RtvIPAddrC = */
/* = Description… Retrieve IP address of current device = */
/* = ——————————————————— = */
/* = CrtCLPgm Pgm( YourLib/RtvIPAddrC ) + = */
/* = SrcFile( YourLib/YourSrcF ) = */
/* =============================================================== */

Pgm ( &IPAddr )

/* ————————————————————— */
/* – Variable declarations – */
/* ————————————————————— */

Dcl &RcvVar *Char ( 892 )
Dcl &RcvVarLen *Char ( 4 ) ( X’0000037C’ )
Dcl &Format *Char ( 8 ) ( ‘DEVD0600′ )
Dcl &DevD *Char ( 10 )
Dcl &APIError *Char ( 8 ) ( X’0000000000000000′ )
Dcl &IPAddr *Char ( 15 )
Dcl &MsgID *Char ( 7 )
Dcl &MsgDta *Char ( 256 )
Dcl &MsgF *Char ( 10 )
Dcl &MsgFLib *Char ( 10 )

/* ————————————————————— */
/* – Global error trap – */
/* ————————————————————— */

MonMsg ( CPF0000 MCH0000 ) Exec( GoTo Error )

/* ————————————————————— */
/* – Retrieve current device name and its dotted IP address – */
/* ————————————————————— */

RtvJobA Job( &DevD )

Call QDCRDEVD +
( &RcvVar +
&RcvVarLen +
&Format +
&DevD +
&APIError )

ChgVar &IPAddr ( %Sst( &RcvVar 878 15 ) )

Return

/* ————————————————————— */
/* – Error handler (percolate error message to caller) – */
/* ————————————————————— */

Error:

RcvMsg MsgType( *Excp ) +
Rmv(*No ) +
MsgDta( &MsgDta ) +
MsgID( &MsgID ) +
MsgF( &MsgF ) +
MsgFLib( &MsgFLib )
MonMsg ( CPF0000 MCH0000 )

SndPgmMsg MsgID( &MsgID ) +
MsgF( &MsgFLib/&MsgF ) +
MsgDta( &MsgDta ) +
MsgType( *Escape )
MonMsg ( CPF0000 MCH0000 )

EndPgm
</pre>

Satsho
===========================================================

Also, if you need the host name you can use the following:
<pre>
PGM
DCL VAR(&NAME) TYPE(*CHAR) LEN(65)
DCL VAR(&SIZE) TYPE(*INT) LEN(4) VALUE(64)

CALLPRC PRC(‘gethostname’) PARM((&NAME) (&SIZE *BYVAL))

SNDPGMMSG MSG(‘Host name = ‘ || &NAME)
ENDPGM
</pre>

<a href=”http://www.aresgrp.com”>Kevin “BigKat” Ketzler</a>

—————–

I believe the program was contributed by Gary Guthrie. Thanks Gary,

—————————————

The preceding program returns the IP address of the display device associated with the current job.

The original question however was how to return/get the IP address of the AS/400 machine and not of the device (though perhaps the question was worded incorrectly). As the system can have multiple IP addresses more information is needed about the environment the CL program is running in. For instance, does the program have a current socket connection? And what in the world does the Java program need a/the external system IP address of the system for anyway?

Bruce Vining
<a href=”http://www.brucevining.com/”>Bruce Vining Services</a>

Discuss This Question: 1  Reply

 
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
  • TomLiotta
    Just a minor comment... One reason a program might need to know the local IP address is to insert it as text in an outbound message of some sort. A particular case is IBM's Site Protector product (originally from ISS). It requires the host IP address be embedded as text in the event message from the System i to the Site Protector agent. It took a bit of thought to get the APIs in the proper sequence when I had to do that, and it sure wasn't done in CL. It's rare that any program needs to know where it's coming from instead of where it's going to. I think it can be done with V5R4 ILE CL; I don't see why not, though I haven't tried. I suspect that those who can do it would use a different language. 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