【发布时间】:2011-08-02 14:16:13
【问题描述】:
我有一个调用其他程序的 Perl 脚本,即它使用管道调用 system 和/或 exec 和/或 open 和/或使用反引号运算符。
我能否以这样的方式运行这个脚本,它会打印出上述每个参数的参数,以便我可以看到它正在调用什么?
例如像这样的程序我无法修改
#!/usr/bin/perl
sub get_arg {return "argument$_[0]";}
system "./foo", get_arg(1), get_arg(2);
print `./foo abc def`;
调用了类似这样的东西
perl --shell-trace-on ./myscript.pl
在这种情况下会输出
./foo argument1 argument2
./foo abc def
丢弃 myscript.pl 的正常输出或将其与此跟踪混合是可以接受的。
非常感谢。
【问题讨论】:
-
所以你想让脚本看看shell扩展后的命令是什么样子的?
-
我想捕获外部程序的执行及其参数。
标签: perl debugging shell shellexecute system-calls