Telnet CL program on AS/400

20 pts.
CL Program
Does anyone know if it is possible to write a CL or RPG program that will automate a telnet session to a second device to change data? I have a multiple fuel controllers that I need to telnet into daily and change the current fuel price. I would like to automate this. Does any onw know how to do it from the an AS/400?   Thanks.

Software/Hardware used:
Iseries V5.4

Answer Wiki

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

Are you sure TELNET is the best solution?

Is it possible to to pass the data with FTP.
Or SQL using the CONNECT option.

These three could be automated easily and have table values set up for easy maintenance.


Some alternative to telnet would definitely be preferable. With that said —

Yes, both CL and RPG can do it, with some general restrictions.

  1. It requires proficiency with whichever language is used. By asking the question, it seems difficult to believe that this condition is met.
  2. For CL, it would need to be on a V5R4 system or higher, and it would need to be ILE CL.
  3. General proficiency in sockets programming is needed.

Telnet is a well defined internet protocol. RFCs describe how it works. A telnet client is mostly just a sockets program that connects to a telnet server, negotiates the session parameters, and then proxies what goes into the keyboard and out to the display with the telnet server. (Simplified, but that’s the basics.)

Bear in mind that System i telnet is structured as TN5250 — intended for devices that support the 5250 data stream. If you can cleanly use green-screen telnet (STRTCPTELN or TELNET commands) to perform these tasks, then maybe alternatives are possible — maybe.

Easiest to start would perhaps be to obtain/install/study Albert York’s TNAPI utility. IIRC, it explicitly connects to the System i telnet server itself; but once that’s done, you can pass in the TELNET command as if you were running green-screen and go from there. It’s not intended for outbound connections, but I don’t think there’s any way it knows that outbound is being established inside of it.

And if the remote can be accessed via dial-up Point-to-Point, then you can go with Interactive Terminal Facility (via STRITF and asysnc) and related functions.


Discuss This Question: 3  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.
  • wkozerski
    No I'm not. I have been doing it manually using telnet that uis why I was trying to use that method. How would I do it using remote command?
    20 pointsBadges:
  • CharlieBrowne
    If your replaceing hte contents of a small file, FTP may be the best. You can search this list and find examples on how to do that. * Another possiblity is the setup DDM files on the target system. Think of this as a LF on your system over data on the source system. Then you can write and run code over those files. * Here is a link for the SBMRMTCMD
    62,385 pointsBadges:
  • WilsonAlano

    As you intend to connect to a system that is not an AS/400 (System i, iSeries, etc.) you may be look at TCP/IP programming and manage Telnet protocol yourself. As Tom said, it's a well known protocol and you can find definitions in google.

    2,710 pointsBadges:

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.

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


Share this item with your network: