[英]Issue in executing a command in perl
I have the below code:我有以下代码:
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
foreach my $testList(@testList) {
chdir "/home/test/test1/$testList";
exec "cat test.out | grep -w 'PASSED'";
}
After I run the above code, it gives the output for only the below:在我运行上面的代码后,它只为以下内容提供 output:
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
but not the other two lines below.但不是下面的其他两行。 I only want the output for the lines:
我只想要 output 的行:
foreach my $testList(@testList) {
chdir "$opts->{/home/test/test1$testList";
exec "cat test.out | grep -w 'PASSED'";
and not并不是
chdir glob "/home/test/test1/test2/perl*";
@testList = exec "cat test.in | grep build | awk '{print \$2}'";
Please help.请帮忙。
exec
and system
are returning exit code. exec
和system
正在返回退出代码。
Try:尝试:
@testList = `cat test.in | grep build | awk '{print \$2}'`;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.