![](/img/trans.png)
[英]How to pass a replacing regex with a backreference as a command line argument to a Perl script
[英]how to pass command line argument to a script which should be run in the background?
如何将命令行参数传递给应该在后台运行的脚本? 我尝试了以下命令,它给出了一个错误:
system("perl sample.pl& 1");
Error: 1: command not found
在后台运行的程序的参数必须放在与号之前:
perl sample.pl 1 &
Shell会将您键入的内容识别为2个单独的命令(假设您使用的是Unix或Linux变体):
perl sample.pl
在后台运行
1
外壳程序报告1不是有效命令的位置。
之所以无效,是因为所有参数都必须在“&”号之前
因此, system("perl sample.pl 1 &");
或者,您可以使用exec()或反引号。 例如`perl sample.pl 1 &`
但是,如果您使用exec,就知道它永远不会返回系统执行的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.