我在perl中执行任务时遇到了问题。通过该脚本,首先我想转到另一条路径,然后执行位于该路径中的命令。
例如:<drive>\Program Files\<software>\bin
,此处的命令是xyz -c
那么,该怎么做?我所做的是 - &gt;
my $command = '<drive>\Program Files\<software>\bin';
$sts = `("$command\\xyz -c")`;
print $sts;
但这不会起作用
Not an internal or external command.
当我手动转到cmd中的这个特定驱动器并执行命令时,它可以工作..
此致 维克
答案 0 :(得分:1)
替换
$sts = `("$command\\xyz -c")`;
与
$sts = `"$command\\xyz -c"`;
再试一次。
要确保使用有效的文件路径,可以用
替换上面的代码if (-f "$command\\xyz") {
$sts = `"$command\\xyz -c"`;
print $sts;
}