Need to create a batch file to send "reload" command through telnet

Hi experts,

I've got a problem with our internet router with the internet going slow in the mornings, this is easily fixed with a physical reboot of the router. I'm yet to find the problem. However, there are workers that get in early at about 6.30am to start work, and I get early morning calls if the internet isn't working :) So I was wondering if it's possible to write a batch file that basically opens up a dos window, writes "telnet (the ip address of the internet router) and then after that, logs in with the password, then once dropped into the internet router's prompt, types "enable" and then "reload"

The router is a Cisco 827

This will cause the router to reload its config and bring the internet back up again, saving me an early morning wakeup call :-)

Can anyone give me a hand with this ?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Could try and script to feed to telnet. I'm not sure if it will work or not, but it's worth a try:

@echo off

(echo username)>_temp.txt
(echo password)>>_temp.txt
(echo enable)>>_temp.txt
(echo reload)>>_temp.txt
(echo quit)>>_temp.txt

type _temp.txt|telnet

del _temp.txt>NUL

You'd have to encode the username and password in the batch processing.

Good Luck,
Unfortunately, the native Windows telnet client doesn't support redirection (and I haven't found a third party tool doing this, either).
The only method I've found so far (short of real programming) when I've been looking into this some years ago was the use of Perl.
Here's an introductory example:
Using perl to connect to remote hosts via telnet
Here's the general library:
Jay Rogers > Net-Telnet-3.03 > Net::Telnet
And here's a special library for Cisco:
Joshua Keroes > Net-Telnet-Cisco-1.10 > Net::Telnet::Cisco

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try using autoexpect to generate the script that you need.  I use it for automatic backups of Cisco configs which requires login, enable. etc.  Once you've created the script, add it to the task scheduler.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

The suggestion of SteveGTR (http:#16433328) would probably work if you use netcat instead of telnet:
Lee W, MVPTechnology and Business Process AdvisorCommented:
I suggest you look at the telnet scripting tool.

As others have already said, the windows telnet tools do not support redirection or scripting and no other telnet I've found does either.  This may be your only hope (a colleague of mine found it and used it to do something quite similar with Cisco devices, if I remember correctly)l.
jaimekleinAuthor Commented:
Wow you guys are great,

Thanks for all the suggestions. I will look at and try them all and see which one works best when I go back to work in a few days time

Thank you once again

cwwkie is correct.

I've personally abandoned Microsoft Telnet Client whenever possible in favor Netcat as a telnet client myself. (One of the differences being that backspace will always work in Netcat but not in Microsoft Telnet Client. Once you use telnet enough, this difference starts to become important.) Netcat does support redirected input, unlike Microsoft Telnet Client. You need to specify a port with Netcat, however. There is no default port for netcat to connect if none are specified.

SteveGTR, why do you enter in this format:
type _temp.txt|nc 23

When it would be at least as effective to simply enter the following?
nc 23<_temp.txt

Alternatively, you could actually have netcat run batch files against the telnet server (ergo, it takes server output as input and sends server input as its output), but it's not too reliable.
> SteveGTR, why do you enter in this format:
> type _temp.txt|nc 23

> When it would be at least as effective to simply enter the following?
> nc 23<_temp.txt

Caudax , you will find out as you develop your MSDOS skills that there are many ways to accomplish the same task :)
If the author is still present, could we hear a response?

>Caudax , you will find out as you develop your MSDOS skills that there are many ways to accomplish the same task :)

I know there are multiple ways to accomplish the same task. It just struck me as odd that you used type "filename"| to accomplish just about the only purpose there is to <.

On a side note, I've been using DOS for... over 11 years now (though I'm not taking offense at the remark; it just merely struck me as comical, given the circumstances).
Good point. No offense implied :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.