- 论坛徽章:
- 0
|
本帖最后由 Perl_Er 于 2012-03-01 13:20 编辑
- exec PROGRAM LIST
- perl认为LIST里面的第一个参数是你要执行命令的名字,但实际上是执行的PROGRAM。比如:
- my $cmd = 'ls';
- my @args = ( "command","surprise" );
- exec { $cmd } @args;
- # ./test.pl
- command: surprise: No such file or directory --> 这里系统显示你执行了command, 程序实际执行的ls,但是却告诉你是执行的command。 这里被骗了。
- 本来应该显示:
- ls: surprise: No such file or directory
- This always forces interpretation of the LIST as a multivalued list, even if there is only a single scalar in the list.
- Using an indirect object with exec or system is also more secure. This usage (which also works fine with system()) forces interpretation of the arguments as a multivalued list, even if the list had just one argument. That way you're safe from the shell expanding wildcards or splitting up words with whitespace in them.
复制代码 回复 7# 午夜凋零
|
|