Are you sure TELNET is the best solution?
Is it possible to to pass the data with FTP.
Or a SBMRMTCMD,
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.
- It requires proficiency with whichever language is used. By asking the question, it seems difficult to believe that this condition is met.
- For CL, it would need to be on a V5R4 system or higher, and it would need to be ILE CL.
- 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.