Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: login to telnet from batch script  (Read 99066 times)

0 Members and 1 Guest are viewing this topic.

ann124

  • Guest
login to telnet from batch script
« on: November 23, 2004, 06:55:58 AM »
I was able to set up a batch file to open a telnet session, but I still have to type in my username and password for the session to actually start. Is there any way to set up the batch file to automatically enter my username and password? ???

tamby1981

  • Guest
Re: login to telnet from batch script
« Reply #1 on: January 14, 2005, 08:19:45 AM »
Hello friend
Please if you find a solution for this problem please send it to my mail address
[email protected]

Zzyzx

  • Guest
Re: login to telnet from batch script
« Reply #2 on: January 14, 2005, 09:52:02 AM »
Try using some Telnet switches:

Examples:

telnet -a 192.168.2.1

or

telnet -l username 192.168.2.1

There is no switch for the password. The "a" switch will try automatic logon using your signon from your machine. The "l" switch allows you to enter any username.

Hope this helps.
8)

MMaverick

  • Guest
Re: login to telnet from batch script
« Reply #3 on: January 15, 2005, 05:38:33 AM »
You can also try having dos automatically put some input to the program through piping with the echo command.

See the following example:
Code: [Select]
echo y|copy file1.zip "D:\Program Files\file1.zip"

The echo pipes "y" to the copy program which is the answer to the question "Do you want to overwrite the existing file".

Maybe you can do the same with telnet

z_c00l

  • Guest
Re: login to telnet from batch script
« Reply #4 on: May 21, 2007, 07:45:28 PM »

This is good. from this command we can login the username, but how do we login the password?

Try using some Telnet switches:

Examples:

telnet -a 192.168.2.1

or

telnet -l username 192.168.2.1

There is no switch for the password. The "a" switch will try automatic logon using your signon from your machine. The "l" switch allows you to enter any username.

Hope this helps.
 8)

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: login to telnet from batch script
« Reply #5 on: May 22, 2007, 03:50:12 AM »
Like a phoenix rising from the ashes, old posts spring forth to haunt us. You do realize this post is over 2 years old, right?

You may need a working knowledge of how telnet prompts for parameters. Try combining the two responses above:

echo password | telnet -l username IPaddress

Be aware that putting unencrypted passwords into scripts/batch files is a security breach. Many programs will choke on the pipe; let's hope Microsoft followed their own standards.

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

z_c00l

  • Guest
Re: login to telnet from batch script
« Reply #6 on: May 22, 2007, 06:12:52 AM »
Thanks for the reply..
I'm not too sure where this comes in...

I have created a ".BAT" file inside it has this commands

----------------------------------------
c:\windows\system32\telnet.exe
----------------------------------------

this will open the telnet. Where do I go from here?
I would like to login the username and password using the BAT file. is this possible?


Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: login to telnet from batch script
« Reply #7 on: May 22, 2007, 06:46:54 AM »
Did you run what was posted?

echo password | telnet -l username IPaddress

What were the results? Can you post the console output. If  telnet cannot accept input from the pipe, it may be possible to redirect input from a file, but it will be necessary to see the sequence telnet requests the input.

Of course telnet may only take the password from the keyboard in which case you will be SOL.

Let us know. 8)

If the telnet userid and password are the same ones you use for Windows, try using the -a switch:

Code: [Select]
telnet -a IPaddress
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

ghostdog74



    Specialist

    Thanked: 27
    Re: login to telnet from batch script
    « Reply #8 on: May 22, 2007, 07:57:51 AM »
    alternatively you can use other languages such as Perl that  has telnet modules to do this task.
    eg
    Code: [Select]
        use Net::Telnet ();
        $t = new Net::Telnet (Timeout => 10,
                              Prompt => '/bash\$ $/');
        $t->open("hostname");
        $t->login($username, $passwd);
        @lines = $t->cmd("who");
        print @lines;
    more information here if you are interested.

    georgd



      Newbie

      • Experience: Beginner
      • OS: Windows 7
      Re: login to telnet from batch script
      « Reply #9 on: July 23, 2014, 11:25:28 PM »
      Yes. It is possible with help of another executable called telnetd.exe. I have developed this executable to automate telnetd.exe(http://myresearchdev.blogspot.sg/) session using windows batch file.

      Usage

      telnetd.exe script.txt

      scripts.txt -> for the telnet commands



      After the execution of the batch file you can seelogs from telnetlog.txt. This telnetlog.txt will help you to troubleshoot the commands and responses.