#!/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 = <$sock_2> )
{
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
}
}
}
}
阅读(1524) | 评论(0) | 转发(0) |