07-23-07 12:17 AM
Given the following
#!/usr/bin/perl -w
use IO::Socket;
my($handle, $line, $kidpid);
$handle =3D IO::Socket::INET->new(
PeerAddr =3D>"137.104.128.2",
PeerPort =3D>"23",
Proto=3D>"tcp",
)
or die "cant connect to port: $!";
$handle->autoflush(1);
print STDERR "[Connected]\n";
die "can't fork: $!" unless defined($kidpid =3D fork());
if($kidpid) {
while(defined($line =3D <$handle> )){
print STDOUT $line;
}
kill("TERM", $kidpid);
}
else {
while(defined ($line =3D <STDIN> )){
print $handle $line;
}
}
When I run it, I get
[cdalten@localhost]$ ./foo.pl
[Connected]
now, when I hit the 'enter' key on my keyboard, I get
?????
University of Wisconsin - Platteville (pine.ucs.uwplatt.edu)
Then after a few seconds, I get
Username:
Error reading command input
However, what I really want to see is
Trying 137.104.128.2...
Connected to uwplatt.edu (137.104.128.2).
Escape character is '^]'.
University of Wisconsin - Platteville (pine.ucs.uwplatt.edu)
Username:
What's my error in logic?
[ Post a follow-up to this message ]
|