in reply to Re^2: Logging into telnet using a socket
in thread Logging into telnet using a socket
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 |