如何从perl脚本调用shell脚本

如何从perl脚本调用shell脚本,perl,Perl,我试图从perl脚本调用已经保存的shell脚本,但它不起作用 1.pl: commands.sh: #!/bin/csh -f echo "calling shell script from perl script"; 如果commands.sh是可执行的,那么您只需要: #!/usr/bin/perl system("/path/to/commands.sh") 如果commands.sh未设置可执行标志,则 #!/usr/bin/perl system("/bin/csh /pa

我试图从perl脚本调用已经保存的shell脚本,但它不起作用

1.pl:

commands.sh:

#!/bin/csh -f

echo "calling shell script from perl script";

如果commands.sh是可执行的,那么您只需要:

#!/usr/bin/perl

system("/path/to/commands.sh")
如果commands.sh未设置可执行标志,则

#!/usr/bin/perl

system("/bin/csh /path/to/commands.sh");

所有其他代码似乎都是多余的

对于我来说,shell脚本的路径不时会改变,因此我将其保存在脚本顶部的一个变量中,以便更新:

我们的
$pathToShellScript='/path/to/script.sh'

system("/bin/sh $pathToShellScript");
不确定此错误的原因:

sh:-c:第0行:查找匹配项时出现意外EOF`

而以下工作:
系统(“/bin/sh”,“$renamingScript”)

用鼠标选择代码,然后单击
{}
按钮将其格式化为代码。为什么要使用?你说的“它不起作用”是什么意思?尝试检查.Is commands.sh的返回值是否与1.pl位于同一目录中?也许这条路不对。尝试使用commands.sh的绝对路径,看看是否有帮助。shell脚本的顶部显示
#/bin/csh
但是你用
/bin/sh
来称呼它,为什么?此外,还应检查
system
的返回值是否存在错误,最小值为
system(“/bin/sh commands.sh”)==0或die“\$?=$?”
system("/bin/sh $pathToShellScript");