jaimeklein
asked on
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 123.123.235.125 (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 ?
Thanks,
jaimeklein
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 123.123.235.125 (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 ?
Thanks,
jaimeklein
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The suggestion of SteveGTR (http:#16433328) would probably work if you use netcat instead of telnet: http://www.vulnwatch.org/netcat/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
jaimeklein
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
jaimeklein
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 123.123.235.125 23
When it would be at least as effective to simply enter the following?
nc 123.123.235.125 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.
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 123.123.235.125 23
When it would be at least as effective to simply enter the following?
nc 123.123.235.125 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 123.123.235.125 23
>
> When it would be at least as effective to simply enter the following?
> nc 123.123.235.125 23<_temp.txt
Caudax , you will find out as you develop your MSDOS skills that there are many ways to accomplish the same task :)
> type _temp.txt|nc 123.123.235.125 23
>
> When it would be at least as effective to simply enter the following?
> nc 123.123.235.125 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).
>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 :)
@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 123.123.235.125
del _temp.txt>NUL
You'd have to encode the username and password in the batch processing.
Good Luck,
Steve