G
grocery_stocker
Given the following
#!/usr/bin/perl -w
use IO::Socket;
my($handle, $line, $kidpid);
$handle = IO::Socket::INET->new(
PeerAddr =>"137.104.128.2",
PeerPort =>"23",
Proto=>"tcp",
)
or die "cant connect to port: $!";
$handle->autoflush(1);
print STDERR "[Connected]\n";
die "can't fork: $!" unless defined($kidpid = fork());
if($kidpid) {
while(defined($line = <$handle>)){
print STDOUT $line;
}
kill("TERM", $kidpid);
}
else {
while(defined ($line = <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?
#!/usr/bin/perl -w
use IO::Socket;
my($handle, $line, $kidpid);
$handle = IO::Socket::INET->new(
PeerAddr =>"137.104.128.2",
PeerPort =>"23",
Proto=>"tcp",
)
or die "cant connect to port: $!";
$handle->autoflush(1);
print STDERR "[Connected]\n";
die "can't fork: $!" unless defined($kidpid = fork());
if($kidpid) {
while(defined($line = <$handle>)){
print STDOUT $line;
}
kill("TERM", $kidpid);
}
else {
while(defined ($line = <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?