Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: telnet and bash

  1. #1
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    telnet and bash

    Is it possible from bash to

    #1 telnet to a host
    #2 automaticly type in user & password
    #3 execute a command
    #4 close the telnet session

    Thanks on advance.
    Kind Regards.

  2. #2
    Join Date
    Jul 2009
    Location
    127.0.0.1
    Beans
    54
    Distro
    Ubuntu

    Re: telnet and bash

    Yes, i'm sure it's possible... Look at telnet program options or perhaps a tool like netcat could help you...
    be XOR !be

  3. #3
    Join Date
    May 2006
    Beans
    1,787

    Re: telnet and bash

    Quote Originally Posted by Drenriza View Post
    Is it possible from bash to

    #1 telnet to a host
    #2 automaticly type in user & password
    #3 execute a command
    #4 close the telnet session

    Thanks on advance.
    Kind Regards.
    I think there is a telnet implementation in python. You could also use 'expect'.

    Does it have to be telnet? If you can set up things to use 'ssh', you can execute commands remotely with it.

  4. #4
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: telnet and bash

    i have looked at expect scripting.

    And are stuck. After i connect to the remote host (with telnet) how to i execute the command and close the session again?

    Code:
    #!/usr/bin/expect -f
    
    set timeout 10
    spawn telnet xx.xxx.xxx.xxx
    expect "login"
    send "username\r"
    expect "Password"
    send "password\r"
    after the send "password\r"
    i want to execute a command. But do you just type send infront of the command to send / execute it??
    or how do you do it.
    Last edited by Drenriza; January 7th, 2011 at 03:30 PM.

  5. #5
    Join Date
    Dec 2009
    Location
    germany
    Beans
    1,020
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: telnet and bash

    Quote Originally Posted by Drenriza View Post
    i have looked at expect scripting.

    And are stuck. After i connect to the remote host (with telnet) how to i execute the command and close the session again?

    Code:
    #!/usr/bin/expect -f
    
    set timeout 10
    spawn telnet xx.xxx.xxx.xxx
    expect "login"
    send "username\r"
    expect "Password"
    send "password\r"
    after the send "password\r"
    i want to execute a command. But do you just type send infront of the command to send / execute it??
    or how do you do it.
    hi
    just a hint.
    every hacker will be very happy if you are using telnet ( sorry if i'am wrong and you are using telenet via a
    vpn ).
    why you are not using the ssh ???.
    on the other side you have to look at the configuration on the oter side of your confirguration.
    telnet can do that - but how are all the routers and switches are configured ?.
    ciao
    "What is the robbing of a bank compared to the FOUNDING of a bank?" Berthold Brecht

  6. #6
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: telnet and bash

    Why do I get a feeling that this is a foundation network device?
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  7. #7
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,040
    Distro
    Xubuntu

    Re: telnet and bash

    Quote Originally Posted by Drenriza View Post
    i have looked at expect scripting.

    And are stuck. After i connect to the remote host (with telnet) how to i execute the command and close the session again?

    Code:
    #!/usr/bin/expect -f
    
    set timeout 10
    spawn telnet xx.xxx.xxx.xxx
    expect "login"
    send "username\r"
    expect "Password"
    send "password\r"
    after the send "password\r"
    i want to execute a command. But do you just type send infront of the command to send / execute it??
    or how do you do it.
    I would be inclined to wait for a prompt before sending the command, maybe like
    Code:
    expect "$"
    send "do something awesome\n"
    and wait for some indication that it has finished before logging out:
    Code:
    expect "Done"
    send "logout"

  8. #8
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: telnet and bash

    Rnerwern. The telnet session is only local so it is limited to the trouble it can make. But im aware that telnet is very insecure .

    Slavik. Not sure what you mean.

    The cog. Intersting, i will try to look at this.

  9. #9
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: telnet and bash

    Quote Originally Posted by Drenriza View Post
    Rnerwern. The telnet session is only local so it is limited to the trouble it can make. But im aware that telnet is very insecure .

    Slavik. Not sure what you mean.

    The cog. Intersting, i will try to look at this.
    foundation network device = switch, router, hub (if anyone still uses those), firewall, AP
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  10. #10
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: telnet and bash

    Quote Originally Posted by Drenriza View Post
    Rnerwern. The telnet session is only local so it is limited to the trouble it can make. But im aware that telnet is very insecure .

    Slavik. Not sure what you mean.

    The cog. Intersting, i will try to look at this.
    foundation network device = switch, router, hub (if anyone still uses those), firewall, AP
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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