in reply to Re: Logging into telnet using a socket
in thread Logging into telnet using a socket

Monarch Your code appears to be the solution that I am looking for. When I attach that snippet to my current program it hangs at the command prompt.

I then login to the linux box that telnet is running on and run a who and the user that I am connecting with is not listed...

If this is it then I will follow my Camel and do a local install of Net::Telnet.

Thanks for the input

EDIT: Castway, It is a limited functionality telnet server. The user that I am using does not require a password but all other users on the server do require a password

  • Comment on Re^2: Logging into telnet using a socket

Replies are listed 'Best First'.
Re^3: Logging into telnet using a socket
by monarch (Priest) on Oct 28, 2005 at 00:01 UTC
    Have you tried littering the above code with tracing commands to see what is being received from the box you're connecting to? Sometimes you need to initiate a telnet connection with a "\n" just to kick it into life and send a prompt.

    e.g.

    my ( $r, $resp ); # kick the connection into life with a carriage return print $sock "\n"; # read in from the connection while (sysread($sock, $r, 1024) >= 1) { print( STDERR "At " . scalar(localtime(time())) . " received '$r'\n" ); $resp .= $r; $resp =~ /prompt>/ and last; } # print username to socket print( STDERR "Sending username..\n" ); print $sock "$username\n"; # debugging loop just to see what we're getting while (sysread($sock, $r, 1024) >= 1) { print( STDERR "At " . scalar(localtime(time())) . " received '$r'\n" ); $resp .= $r; }

    Note you can use the strace command as the root user on a linux box to attach tracing to your script. It will give you an idea of what text is coming and going from your socket. Very useful for debugging.

      Monarch,

      Hmmm... I am not going to have a chance to try this out until tomorrow. I will definitely try this out as soon as I get into work and see what we receive.

      I do not have access to the root user on the linux box so I am unsure of how to run the strace.