[英]How to execute perl script from a Windows Powershell script
I have the below PowerShell
code: 我有以下
PowerShell
代码:
$HOME_DIR=[Environment]::GetEnvironmentVariable("HOME")
$WORKING_PATH="C:\tests\automation"
$TOOLS_PATH="$WORKING_PATH\Tools"
Start-Process -FilePath "$HOME_DIR\perl\perl.bat" "$TOOLS_PATH\my_perl_script.pl" -ArgumentList 'arg1' 'arg2' -NoNewWindow
I'm getting error: 我收到错误消息:
Start-Process : A positional parameter cannot be found that accepts argument 'C:\tests\automation\Tools\my_perl_script.pl'.
At C:\RunUIAutomaionTests.ps1:46 char:14
+ Start-Process <<<< -FilePath "$HOME_DIR\perl\perl.bat" "$TOOLS_PATH\my_perl_script.pl"
-ArgumentList 'arg1' 'arg2' -NoNewWindow
  + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException
  + FullyQualifiedErrorId :<br>  PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
What I'm missing?How should I execute my_perl_script.pl
using perl.bat
with the arguments 'arg1'
and 'arg2'
? 我缺少什么我应该如何使用带有参数
'arg1'
和'arg2'
perl.bat
执行my_perl_script.pl
?
Why so complicated? 为什么这么复杂? You can call perl doirectly like that: ...
您可以像这样直接调用perl:...
$TOOLS_PATH="$WORKING_PATH\\Tools" ...
$ TOOLS_PATH =“ $ WORKING_PATH \\ Tools” ...
perl $TOOLS_PATH\\my_perl_script.pl arg1 arg2 perl $ TOOLS_PATH \\ my_perl_script.pl arg1 arg2
Just make sure perl executable is in Windows path 只要确保perl可执行文件在Windows路径中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.