Link to home
Create AccountLog in
Microsoft DOS

Microsoft DOS

--

Questions

--

Followers

Top Experts

Avatar of rortiz77
rortiz77

Need a batch script that will telnet into a server and run a command
Looking for a batch script that will establish a telnet connection and then run a command.  Is this even possible?

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of activematxactivematx🇺🇸

Try combining:

echo password | telnet -l username IPaddress

Be aware that putting unencrypted passwords into scripts/batch files is a security breach.

Alternatively you could use other languages such as perl to do this task:

    use Net::Telnet ();
    $t = new Net::Telnet (Timeout => 10,
                          Prompt => '/bash\$ $/');
    $t->open("hostname");
    $t->login($username, $passwd);
    @lines = $t->cmd("who");
    print @lines;

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of activematxactivematx🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of rortiz77rortiz77

ASKER

@activematx, your right...don't want to free text my password in there. How does this other tool not store my password? Kinda hard to make sense of it so far...

Avatar of activematxactivematx🇺🇸

How does this other tool not store my password?

This other tool will also store your password in a text file.  :(

Here is a write up of what the program does.  Link:  http://jerrymannel.com/blog/2008/11/11/telnet-scripting-tool-aka-tst10exe/

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of B_DenisonB_Denison🇺🇸

How about using PuTTY to fo this?

Avatar of skraazskraaz🇮🇳

Hi SecureCRT is the BEST tool to do this automation..

Learn to use from the below link..
http://www.vandyke.com/products/securecrt/

I am using the same for telnet and run the commands which are preloaded.

Attached are the screenshots..just for reference..

Cheers!
secureCRT1.JPG
secureCRT1.JPG

@B_Denison @skraaz,

I'm all for telnet but this needs to be something that the SQL server can execute.  If so, then its a good option.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Ok, spoke with our admin and he has no concerns with using this Telnet script Tool.  His server is secured enough...so he's good to go.  

I've done some testing and I can't get passed the logon part.  What I've done so far is that I have a text file called, "logon.txt" and an "Output.txt" file which is blank.  

My logon.txt file contains:

128.#.#.# 23
WAIT "login"
SEND "username\m"
WAIT "password"
SEND "$1234\m"
WAIT ">"
SEND "ss1\m"
WAIT ">"
SEND "stop_procs\m"
WAIT ">"

I then go to the cmd and type:
TST10.exe /r:logon.txt /o:output.txt /m
but it fails to get passed the username/password.

It then shows this:
Welcome to Microsoft Telnet Service 
login: hciuser
ciuser
password: $eveN11
The handle is invalid.

Login Failed
login: 

Open in new window


ok, figured out the bug.  Since it always wanted me to re-enter the username and password...then the solution is to put that in twice in the script.  Seems to work so far.

Avatar of Bill PrewBill Prew

For what it's worth, here's another approach using the built in windows telnet client, and VBScript to automate the usage of that "command line" program.  You may be all set, but thought I'd pass it along...

http://www.makeuseof.com/tag/automate-telnet-commands-vb-script/

~bp

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Microsoft DOS

Microsoft DOS

--

Questions

--

Followers

Top Experts

Microsoft Disk Operating System (MS-DOS) was an operating system for x86-based personal computers, and traces of it are still found in the Windows operating system. DOS is still used in some embedded systems and for certain legacy 16-bit networks.