小编han*_*ish的帖子

Perl:实现套接字编程( system() 从不返回)

我的目标:实现套接字编程,如果服务器未安装在远程机器上,客户端会尝试连接到服务器,客户端(主机)将 tar 文件传输到服务器(目标)机器和 perl 脚本。这个 perl 脚本解压文件夹并运行一个脚本(服务器 perl 脚本),现在的问题是:这个服务器脚本必须永远运行(多个客户端),直到机器重新启动或发生一些不愉快的事情。所以脚本运行正常:但是由于它一直在运行,因此控件不会返回到客户端,客户端将再次尝试连接到服务器(在某个预定义的套接字上),所以基本上我希望以某种方式运行服务器但带回控制到我的主机,在这种情况下是客户端。

这是代码:

my $sourcedir = "$homedir/host_client/test.tar";
my $sourcedir2 = "$homedir/host_client/sabkuch.pl";
my $remote_path = "/local/home/hanmaghu";

# Main subroutines
my $ssh = Net::OpenSSH->new ( $hostmachine, user =>$username, password => $password);
$ssh->scp_put($sourcedir,$sourcedir2,$remote_path)
     or die "scp failed \n" . $ssh->error;
# test() is similar to system() in perl openssh package
my $rc = $ssh->test('perl sabkuch.pl'); 
# check if test function returned or not -> this is never executed
if ($rc == 1) {
    print "test was …
Run Code Online (Sandbox Code Playgroud)

sockets perl fork openssh system

1
推荐指数
1
解决办法
218
查看次数

如何从perl中更改字符串中提取值

我想从字符串中提取一个值(不断变化)以便进一步处理.

字符串是

TPSM seed 4339CD65   pass 1  x 0 x 1  errors 0 pid 179947 rulefilecycle 0
TPSM seed 5339CD60   pass 1  x 9 x 2  errors 0 pid 179947 rulefilecycle 0
TPSM seed 2339CD61   pass 1  x 101 x 5  errors 0 pid 179947 rulefilecycle 0
TPSM seed 5339CD65   pass 1  x 19 x 6  errors 0 pid 179947 rulefilecycle 0
TPSM seed 9339CD65   pass 1  x 100 x 7  errors 0 pid 179947 rulefilecycle 0
Run Code Online (Sandbox Code Playgroud)

我希望在传递 1 …

regex perl

-2
推荐指数
1
解决办法
75
查看次数

标签 统计

perl ×2

fork ×1

openssh ×1

regex ×1

sockets ×1

system ×1