AUTOMATING TELNET COMMANDS USING WINDOWS BATCH FILE
Telnetd is a software application designed to facilitate automated execution of telnet commands from the Windows operating system. It can be initiated through a straightforward batch file, enabling you to schedule its automatic execution based on triggers from the Windows scheduler. Telnetd is compatible with various telnet servers, including network switches, routers, and UNIX boxes. It communicates with devices adhering to the RFC 854 protocol definition. This program has undergone testing across different Windows operating systems, including Windows XP, Win7, Win11 (both x86 and x64). A single script file is capable of incorporating telnet commands for over 100 devices, executing them sequentially. Telnetd stands out for its reliability and superior speed when compared to conventional tools.
The Telnet program processes commands from a specified text file, which is provided as a command line argument, as demonstrated by the syntax "telnetd.exe mycommands.txt." To configure your telnet commands, you must set up the mycommands.txt file. The sample script, cvstart.txt, accompanying the trial version, contains a series of telnet commands. This program, however, dynamically selects commands to send to the telnet server based on the preceding response from the server, without utilizing a send key method. Extensive testing has been conducted with various network switches and routers, confirming the program's efficacy. It is designed to be scheduled for execution at multiple intervals, ensuring its adaptability and reliability in diverse environments.
I'm pretty impressed with what you've built with Telnetd, Aaron Estrada
Telnet Features
Feature | Description |
---|---|
1. | No delays in between the telnet commands |
2. | Provides faster execution and does not need to wait for timeouts |
3. | Does not require focus on the console window |
4. | Can configure to run in background mode without launching the console window |
5. | Auto recovery when routers/switches do not respond or do not send the expected text |
6. | Saves logs for troubleshooting and auditing purposes |
7. | Configurable to run silently in a minimized window and can be scheduled for automatic execution |
8. | No software installation is required. Just copy to any location and configure it. Ad-free. |
9. | Maintains two types of logs: default telnet execution log with timestamps and pure logs (exact log from the telnet window) will be created if the user passes a 3rd argument (file name) along with telnetd command. |
Installation/Download Procedure
Step | Procedure |
---|---|
1. | Download the zip file from the provided URL link and unzip it to a folder. |
2. | Open the CVSTART.txt file and insert the IP address and port number (default port is 23). |
3. | Add the login prompt and username (if the server requires a login). |
4. | Include the password prompt and password. |
5. | Add your commands and expected text sequentially. |
6. | Include the "exit" command. |
7. | Open the Restart.bat file (modify CVSTART.txt if you have a different file name and save). |
8. | Launch the restart.bat program and verify the output of the program. |
Note: Watch the below video if you are not clear about the steps.
How to setup your commands
Commands | Descriptions |
---|---|
TELNETID=server1 | TelnetId serves as an identifier for different telnet sessions within the same file. The sample file, however, only contains one session. |
IP=15.45.117.111 | This indicates the IP address of the telnet server, router, or switch. |
PORT=23 | The port setting, unless the telnet server is listening on a different port, typically requires no changes. |
RETRY=1 | Specifies the number of attempts made to establish a connection with the telnet server before giving up. |
TIMEOUT=10 | Used to exit the session by sending ENTER (CRLF) or a new line twice with a gap of 10 seconds in the absence of a server response. |
SLEEP=0 | The waiting time before initiating the next telnet session on the same file. In this sample, it is not required as there is only one session. |
1->login: =root | "1" represents the sequence id, "->" is the specified format. "login" is the expected text from the server, and "root" is your username. |
2->Password:=Password1234 | Follows the same syntax as the login. It ensures the string from the server matches the specified text here in this line, "Password:". |
3->bin >=kill -9 `ps -ef | grep program | grep -v grep |awk 'NR == 1;'|awk '{print $2}'` | This command is used to terminate an application without specifying the PID. It is designed to kill the application named "program". After a successful login, the prompt may vary (e.g., root#, #, root$); in this case, the prompt is "bin >". |
4->bin >=./program& | This command is used to start the application as a new instance. |
5->NULL-SLEEP%700=EXIT | "EXIT" is the key used to exit the program. "NULL-SLEEP" can be utilized where the client does not expect a response from the server. Here, "%700" denotes waiting 700 milliseconds before sending the next command. |
The telnet program generates a file called telnetlog.txt, providing a record of responses received from the telnet server. This log file enables users to review server responses and adjust the script accordingly. As the log file reaches a size of 5MB, it automatically undergoes renaming to telnetlog1.txt, with older versions being removed automatically. This automated process eliminates the need for manual housekeeping tasks. A video demonstrating the procedures, accompanied by visual instructions (without audio explanations), has been included for user convenience.
1 Comments
Jerzy Kręglewski Reply
HI! I found your telnetd v.1.0 very useful for batch reconfiguration of LAN switches in my Customer sites