betahost.blogg.se

How to use telnet in a script
How to use telnet in a script





how to use telnet in a script
  1. HOW TO USE TELNET IN A SCRIPT HOW TO
  2. HOW TO USE TELNET IN A SCRIPT INSTALL
  3. HOW TO USE TELNET IN A SCRIPT PASSWORD
  4. HOW TO USE TELNET IN A SCRIPT WINDOWS

Then use the Start a Program option and browse to the script file that you’ve created. Open up the Task Scheduler and create a new Basic Task, giving it a name and a schedule - daily at a certain time would work.

HOW TO USE TELNET IN A SCRIPT WINDOWS

Scheduling in Windows with a Scheduled Task vbs extension, and then you can double-click on it any time you want to reboot the router. Set oShell= Wscript.CreateObject("WScript.Shell") You may need to edit the script for different commands.

HOW TO USE TELNET IN A SCRIPT PASSWORD

Now you can paste the following into Notepad, but change out the router IP if necessary, and change the mypassword line to be your actual password instead. First you’re going to need to go into Control Panel, get to the “Turn Windows features on or off” panel (just search for it), and then enable the Telnet Client.

how to use telnet in a script

If you’re running Windows, it’s a lot more complicated to schedule this automatically, but we can definitely script it out easily enough. This will reboot your router at 7:01 AM each morning. Or you can add it to your cron like this (on OS X or Linux): crontab -eĪdd this line somewhere: 1 7 * * * (sleep 3 echo admin sleep 3 echo mypassword sleep 3 echo system reboot sleep 3 ) | telnet 192.168.1.1 You can put this into a shell script and run it whenever you want.

how to use telnet in a script

The final command will reboot the server immediately: (sleep 3 echo admin sleep 3 echo mypassword sleep 3 echo system reboot sleep 3 ) | telnet 192.168.1.1

how to use telnet in a script

First we’ll echo the username and password, and then we’ll echo the reboot command, and each time we’ll wait three seconds between. The solution? Use the sleep command!Īdding in a couple of sleep 3 commands, to wait three seconds, solves the problem. So if you pipe in an “echo admin” and then “echo password,” it will happen too quickly and won’t be sent to the server. The only problem is the nagging login that you have to get through… it doesn’t show up right away. All you need to do is something like this: (echo commandname echo anothercommand) | telnet 192.168.1.1 It’s surprisingly easy to script a set of command and pipe them into the telnet application.

HOW TO USE TELNET IN A SCRIPT INSTALL

We’re going to assume you have access to the bash shell, whether that’s in your normal OS, or if your OS (Windows) doesn’t have bash, you might have to install Cygwin. But who wants to do all that typing every time? Scripting Telnet through the Terminal (OS X or Linux or Cygwin on Windows) Once you type the command at the prompt, you’ll be disconnected, and the router will be rebooted. For Verizon FIOS, the option I was looking for was in the system sub-section, and was aptly titled “reboot.” You have to actually type “system reboot” and not just “reboot” though. Once you’re in there, you can usually type the help command to see what the options are. To connect, just type this, substituting the IP address for your own router’s IP if necessary (though most are set to use the 192 range) telnet 192.168.1.1 If you’re using Windows, you’ll probably have to enable telnet. Make sure to click Apply.Īt this point you can easily use telnet from the terminal or command prompt to connect to the router. For the Verizon router, that required going into Advanced -> Local Administration and making sure “Using Primary Telnet Port” is enabled.

HOW TO USE TELNET IN A SCRIPT HOW TO

The first thing you’ll want to do is figure out how to enable telnet on the router. You’ll need to check your router administration panel and see how the options work on there. Note: you can probably do the same thing with a router that isn’t Verizon.







How to use telnet in a script