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

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.

Replies are listed 'Best First'.
Re^4: Logging into telnet using a socket
by mikeock (Hermit) on Oct 28, 2005 at 02:22 UTC
    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.