Results 1 to 10 of 10
  • Thread Tools
  1. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Script a telnet session (Windows XP SP2)

    My network router has a problem which I can work around by logging in on a telnet session and issuing some commands. I need to reissue these commands anytime the router is reset, so I would like to create a .BAT file that automates this.

    Can anyone share an example of a simple .BAT file that connects via telnet and passes commands via the telnet session?

    (here is a log of me issuing these commands manually, IP address and username changed to protect my privacy)
    <code>
    C:> telnet 10.0.0.254

    Username : userx
    Password : ************
    _{userx}=>system config digestauth disabled
    {userx}=>saveall
    {userx}=>exit

    Connection to host lost.

    C:> EXIT
    </code>
    StuartR

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Script a telnet session (Windows XP SP2)

    Stuart

    I've done this with FTP, but never with Telnet, so I don't know how it will react.

    Basically you would create a 'command' file via a BATch file, then point it at Telnet.<pre>(
    echo userx
    echo password
    echo system config digestauth disabled
    echo saveall
    echo exit
    ) > telnet.lns

    telnet 10.0.0.254 < telnet.lns</pre>

    Try the concept with something innocuous (e.g. just do userx/password/exit as the first test!)
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Script a telnet session (Windows XP SP2)

    Unfortunately the telnet client doesn't seem to read from the input file at all. This isn't helped by the fact that the telnet client starts by clearing the screen!

    For a very simple test, I created a file called telnet.txt with username, password and exit, I then entered the command
    <code>telnet < telnet.txt</code>

    from a command prompt and it responded by clearing the screen and outputting
    <code>
    Welcome to Microsoft Telnet Client

    Escape Character is 'CTRL+]'

    Microsoft Telnet> Microsoft Telnet>
    C:Temp>
    </code>


    Regardless of what text I put in the "input file" I just get this same output.

    StuartR

  5. Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Script a telnet session (Windows XP SP2)

    I don't know if it's of any use in your situation, but PuTTY: a free telnet/ssh client allows you to Save then Load telnet sessions, to produce the sort of result you're looking for.

    Alan

  6. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Script a telnet session (Windows XP SP2)

    Alan,

    PuTTy won't do what I need, because it's a GUI product, but the PuTTy page had a command line tool called plink that did exactly what I needed when combined with John's instructions for redirecting the input stream.

    Thanks to both of you.

    StuartR

  7. Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Script a telnet session (Windows XP SP2)

    Sorry, I have used plink myself, but mixed the tools when I referenced them. <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

    Alan

  8. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Script a telnet session (Windows XP SP2)

    I have used PuTTy before, as an interactive SSH client, and nearly replied saying that it wouldn't do what I needed, lucky I actually looked around on their web site first! Thank you.

    StuartR

  9. Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Script a telnet session (Windows XP SP2)

    Stuart

    Glad the combined effort produced satisfactory results! (In 25 years of playing with PCs and servers I think I have used Telnet just once...)
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  10. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Script a telnet session (Windows XP SP2)

    Telnet used to be my favourite tool for testing early web servers, just telnet to port 80 and get index.htm

    StuartR

  11. Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Script a telnet session (Windows XP SP2)

    Strange coincidence. I was just trying that method to reveal the "real" URL in a tinyurl link (as per Scriptlets for URL preprocessing). I can't get a port 80 connection though. Maybe they got sick of everyone telnetting their server ???

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •