我正在嘗試運行一些 strace 命令,如下所示:
my @cmd = shell_quote(@ARGV);
strace -f -o trace.log -e trace=file @cmd
我想查看 trace.log 并在它運行時決議它,并將@cmd stdout 列印到螢屏上。
知道我應該怎么做...幫助:)
sub shell_unquote {
my @strings = (@_);
my $arg;
for my $arg (@strings) {
if(not defined $arg) {
$arg = "";
}
$arg =~ s/'\n'/\n/g; # filenames with '\n' is quoted using \'
$arg =~ s/\\([\002-\011\013-\032])/$1/g;
$arg =~ s/\\([\#\?\`\(\)\{\}\*\>\<\~\|\; \"\!\$\&\'])/$1/g;
$arg =~ s/\\\\/\\/g;
}
return wantarray ? @strings : "@strings";
}
uj5u.com熱心網友回復:
use IPC::Run qw( run );
run \@cmd,
'2>', sub {
# Do something with chunk in $_[0]...
};
或者
use IPC::Run qw( run );
run \@cmd,
'2>', new_chunker, sub {
# Do something with line in $_[0]...
};
uj5u.com熱心網友回復:
cmd您可以cmd使用命名管道與日志決議器同步,而不是從 perl開始:
mknod mypipe p
strace -o mypipe cmd arg arg2 ... argN
并在另一個外殼中
perl -nle '/interesting/ and print' mypipe
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/402198.html
上一篇:使用perl獲取HTMLid標簽
