- 论坛徽章:
- 0
|
#!/usr/bin/perl -w
use IO::Socket;
$ip_addr = '210.75.27.29';$u_port = 5555 ;
$sock_1 = IO::Socket::INET->new( LocalHost => $ip_addr, LocalPort => $u_port, Proto => 'tcp', Listen => 20, Reuse => 1,)or die "no socket:$!";
while ( 1 ){ $sock_2 = $sock_1->accept() or die "accept socket error:$!";; while( $data = ) { print $data; if ( $data =~ /run:/ ) { $my_command = $data; $my_command =~ s/run:/ / ; system ($my_command); }
if ( $data =~ /exit/ ) { $retval = fork(); if ($retval == 0) { close $sock_2; close $sock_1; exit; # this is the parent process } else { print "retval:",$retval,"\n"; close $sock_2; last; # this terminates the child process } } }}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/5591/showart_1212277.html |
|