[Compaq C] Telnet Client Accepting Non Interactive Commands
PRODUCT: Microsoft Visual Studio .NET 2010 (x86_64 and x86) HP C V7.2-022 HP C compiler version A.05.36 GNU gcc compiler version 2.96
OP/SYS: Tru64 UNIX, Version 5.0A HP OpenVMS Alpha, Version 7.3-2 and Above HP OpenVMS IA64 V8.3-1 and above Microsoft Windows 7 Hewlett-Packard HP-UX 11i, V1.6 (B.11.22) (Itanium Processor Family) Hewlett-Packard HP-UX 11i V1.6 (B.11.11) (PA-RISC processor) Linux Fedora 14 Sun-SOLARIS SunOS V5.8 for Ultra-250
SOURCE: Philippe Vouters Fontainebleau/France
LOW-COST HIGH-TECH: http://techno-star.fr
OVERVIEW: This Telnet client works in both interactive and non interactive modes. It can execute from a BATCH file. In both modes, it accepts commands to remote login and so on. Also, the default IP Telnet port (23) is used unless otherwise specified. This has been used to automatically reset to a known state DECserver ports. It can be used for any TCP/IP application, which recognizes ASCII commands on a given IP port.
*** CAUTION *** This sample program has been tested using Visual Studio .NET 2010 on Muicrosoft, Windows 7, HP C V7.2-022 on OpenVMS IA64 V8.3-1H1. However, we cannot guarantee its effectiveness because of the possibility of error in transmitting or implementing it. It is meant to be used as a template for writing your own program, and may require modification for use on your system.
PROGRAM NOTES: Set current directory to the directory containing TELNET.EXE. To activate the program, type the following at an MS-DOS prompt: telnet [-file input-filename] [-I interface] [Iphost [Ipport]] [IPv4 or IPv6] The parameters between square brackets are optionals. If -file or -I parameters are specified, they must appear first in the command. The -I and IPv4 or IPv6 options do NOT apply to Windows. If Iphost is not specified and -file is specified, then input-filename must contain a "connect iphost" command and finished with an "exit". An on-line help is also available. Please, read the README file, for a detailed explaination on available commands and syntax. Windows Information ------------------- c:\ nmake -f Makefile_windows Unix/Linux Information ------------------------ To build the executable, enter the following commands: % gmake Activate it the same way on Windows, providing your PATH includes the search path where the telnet executable resides. OpenVMS information ------------------- To build the executable, perform the following : $ @makefile
PROGRAM: COPYRIGHT (C) 2001-2003 BY HEWLETT-PACKARD COMPANY ALL RIGHTS RESERVED. THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED. THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY HEWLETT-PACKARD COMPANY. HP ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY HP. NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY HEWLETT-PACKARD COMPANY. SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY HP SOFTWARE PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED. ****** * README.TXT ****** Use the following syntax at the MS-DOS prompt to activate the TELNET client: telnet [-file inputfilename] [IPhost [IPport]] For Unix and OpenVMS systems, you may add the [-I interface] and [-af IPv4] or [-af IPv6] options. We are assuming that the default directory contains TELNET.EXE. The line parameters between square brackets are optionals. If "-file inputfilename" is specified, it must appear first in the command line. If IPport is specified, then the IP host name or address must preceed. If an input file is specifed in the command line without the name of a remote Internet host, then the file must contain at least the connect or open commands described below and the exit command. The file must have been created by the simplest text editor like Notepad for Windows, vi for UNIX, and TPU for OpenVMS. The following are commands that this Telnet client accepts at the "TELNET>" prompt: #<space> Parameters: None When placed at the beginning of a line, the line is regarded as a comment. !<space> Same effect as '# ' connect Parameters: <IP Host> required Specify the IP address or IP host name of the remote computer <IP Port> optional (Defaults to port 23) Specify the IP port of the remote utility <Interface> optional Specify the interface which the telnet socket will be bound to. It must appear after the IP Port if this one is specified. <IP version> optional Specify the IP version (IPv4 or IPv6) to create, and eventually bind when the interface is specified, the connection's inet or inet6 socket. It must appear last in the command. This enables Internet Protocol version 4 or 6 when both are used on the same computer. Example: TELNET> connect prssos.evt.cpqcorp.net Connects to remote TELNET server prssos.evt.cpqcorp.net on port 23 TELNET> connect prssos.evt.cpqcorp.net IPv6 Connects to remote TELNET server prssos.evt.cpqcorp.net on port 23, using Internet protocol version 6. TELNET> connect alofi.evt.cpqcorp.net WE0 Connects to remote TELNET server alofi.evt.cpqcorp.net on port 23 and binds the telnet socket so that the traffic uses interface WE0. If the telnet code below has been compiled with _USE_INET6 defined, the interface WE0 must have IPv6 addresses. TELNET> connect alofi.evt.cpqcorp.net 25 tu0 IPv4 Connects to remote TELNET server alofi.evt.cpqcorp.net on port 25 and binds the telnet socket so that the traffic uses interface tu0. The tu0 interface must have an IPv4 address. This is useful if the telnet code below has been compiled with _USE_INET6 defined. open synonym for connect. Accepts the same parameters that connect command. enable Parameter debug Turns on tracing with a hexadecimal dump of the sent and received data. disable Parameter debug Turns off hexadecimal dump. set Parameters user set the initial username before a connection command occurs xdisplay set the initial X terminal display escape_char set the escape character to switch between multiple telnet sessions timeout set the socket inactivity timeout value expressed in seconds unit. Used in non interactive mode for the time to wait before sending the next remote shell command. prompt set the string to be recognized from the flow of ASCII data returned by the remote peer. Designed for non-interactive sessions to speed up the time the script is executed. <prompt or prompt list> set the severity level of the specified prompt or list of prompt to the level expressed right after (fatal or success). If a prompt severity level is set to fatal, this causes the telnet utility to immediatly exit with a failure status if such a prompt is displayed by the remote partner. The prompt or prompt list must already have been specified in a previous "set prompt <prompt or prompt list>" command. Example TELNET> set user "Joe" xdisplay "18.104.22.168:0.0" TELNET> set escape_char "^A" sets the username to "Joe", the X terminal to display 0.0 on remote node 22.214.171.124 and the escape character to CTRL-A. The default escape character is CTRL-]. TELNET> set timeout 10 prompt "SOS6^[[0m > " after the session is resumed, waits 10 seconds before sending the next remote shell command. If the remote peer displays the prompt string, the keyboard thread is immediatly resumed and the next script command is executed, without waiting for the socket inactivity timeout. To enter an escape sequence in the prompt string, enter "^[" for "<ESC>". You can specify multiple prompts, separated with a comma. TELNET> set prompt "Username","login: " TELNET> set "login: " fatal "Username" success recognizes the strings "Username" and "login: " displayed by the remote partner. If the string to be displayed to the terminal screen contains "login: ", this TELNET utility exits with an EXIT_FAILURE (1) exit status. This is to allow some automation with TELNET scripts. To suppress recognition of a prompt or prompts, type: TELNET> set prompt "" help Parameter None display the list of available commands on the screen, as well as a session example. exit Parameter None used to exit from the Telnet utility. quit Parameter None synonym for exit. resume Parameter Optional session number Resumes the first or specified active session number. Example: TELNET> resume 10 resumes the tenth active connection. disconnect Parameter None disconnects the last active session close Parameter None synonym for disconnect show Parameter status display features of all active connections, including per connection default user, display and escape character and some of the TELNET negotiations with the remote computer. Example: TELNET> show status
DOWNLOAD: You can download the project at the URL: ../zip/telnet.zip