Computing.Net > Forums > Programming > Telnet Batch Script UN/PW Problems

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Telnet Batch Script UN/PW Problems

Reply to Message Icon

Name: baer3328
Date: April 12, 2008 at 20:28:52 Pacific
OS: Windows XP Pro SP2
CPU/Ram: P4 2.8Ghz HT/2GB PC2
Product: I made it
Comment:

I'm trying to create an automated script for my coworkers that will allow them to reboot a Wireless Access Point running DD-WRT firmware v23 via telnet with a bat script. I'm somewhat new to scripts, but I've made a few and I know the problem is that the scripts will only pass commands for the command prompt, but won't in any programs that I open within the command prompt.

I have:
telnet <IP address>
root
password
reboot

Obviously that's not flying and if you're reading this you know that the telnet command is the only one passed through. Can anyone tell me how to push the username and password as well as the reboot command through? Or if it's even possible.

I have googled it and looked through the posts, not finding anything that would help me.



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: April 12, 2008 at 21:51:33 Pacific
Reply:

I doubt that it's possible with a batch script, but IVO might prove me wrong.

You really should do this with a proper programming language, such as Perl or Python or VB.


0

Response Number 2
Name: baer3328
Date: April 13, 2008 at 00:58:12 Pacific
Reply:

I don't really know any programming languages. I have a VERY basic knowledge of C++ but that's pretty much the extent. I was just checking to see if I was missing something or if someone knew of a simple quick way to do it.


0

Response Number 3
Name: IVO
Date: April 13, 2008 at 03:10:23 Pacific
Reply:

You are right FishMonger, just a note: that is not possible due to the behavior of MS telnet command not allowing to be scripted at all.

A way to solve baer3328's problem without any programming may be to download TST10.exe tiny and free tool

http://www.freewareweb.com/cgi-bin/...


0

Response Number 4
Name: Razor2.3
Date: April 13, 2008 at 09:51:22 Pacific
Reply:

The native scripting alternative would be to use VBScript, with its SendKeys function, to pass data on to MS' Telnet.


0

Response Number 5
Name: TanelTM
Date: April 14, 2008 at 01:56:09 Pacific
Reply:

I've had the same problem "how to pass commands to telnet with a batch script" my solution was using php. To start the script execute it from example.bat.. of cource you have to download php first and configure the script to your needs.

-[example.php]--------
<?php
$errno = false;
$error = false;
$timeout = 30;
$yourip = "127.0.0.1";
$yourport = "12345";
$fp = fsockopen($yourip, $yourport, $errno, $error, $timeout);
fputs($fp,"root\r");
sleep(1);
fputs($fp,"password\r");
sleep(1);
fputs($fp,"reboot\r");
sleep(1);
fclose($fp);
?>
----------------------

-[example.bat]--------
@echo off
echo Restarting server...
c:\php\php.exe example.php
----------------------


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Gcc installed but invisib... Set a variable to the run...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Telnet Batch Script UN/PW Problems

Batch script www.computing.net/answers/programming/batch-script-/14486.html

Can I speed up my Batch script? www.computing.net/answers/programming/can-i-speed-up-my-batch-script/14412.html

Date Batch Script www.computing.net/answers/programming/date-batch-script/15332.html