Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > the "system" and "print" function thingy

Thread Tools

the "system" and "print" function thingy

flying lumberjack
Posts: n/a
I am currently trying to learn PERL and have a very limited programing
background (QBASIC). So to do this i decided to have a bit of a mess
around with an example of a very basic telnet script from "Erik
Olson's Programming with Perl Modules". With the print function it
allows you to display the text you want to display on the clients
screen. Can you display the results from the "system" function on both
the server and the client, as i can only get it to display the results
on the server screen.

Here is the script (i did't write this):
use IO::Select;

# Create a socket to listen on.
my $listener =
IO::Socket::INET->new( LocalPort => 8008, Listen => 5, Reuse =>
1 );

die "Can't create socket for listening: $!" unless $listener;
print "Listening for connections on port 8008\n";

my $readable = IO::Select->new; # Create a new IO::Select
$readable->add($listener); # Add the listener to it

while(1) {

# Get a list of sockets that are ready to talk to us.
my ($ready) = IO::Select->select($readable, undef, undef,
foreach my $s (@$ready) {

# Is it a new connection?
if($s == $listener) {

# Accept the connection and add it to our readable
my $new_sock = $listener->accept;
$readable->add($new_sock) if $new_sock;

print $new_sock "Welcome!\r\n";

} else { # It's an established connection

my $buf = <$s>; # Try to read a line

# Was there anyone on the other end?
if( defined $buf ) {

# If they said goodbye, close the socket. If not,
# echo what they said to us.
if ($buf =~ /goodbye/i) {
print $s "See you later!\n";

} else {
system ("$buf\n");

} else { # The client disconnected.

print STDERR "Client Connection closed\n";

Reply With Quote
Posts: n/a
"flying lumberjack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...

[snipped long FAQ]

perldoc -f system
perldoc -q "Why can't I get the output of a command with system()?"


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you attach this thingy? bigal Hardware 46 04-07-2006 05:14 AM
2.5 lcd and diopter thingy certsnsearches Digital Photography 1 10-29-2004 07:38 PM
java dropdown transfer thingy question M.E. Java 0 06-22-2004 12:40 AM
How to combine the LEFT and VbCrLF thingy with a single text fiiled ... Evertjan. ASP General 2 11-23-2003 08:15 PM
How to combine both LEFT and VbCrLf thingy to a single field while displaying techy techno Javascript 1 11-23-2003 09:35 AM