我必须将UNIX Shell脚本转换为PowerShell脚本。该脚本在ImageMagick上运行转换。当我尝试执行以下代码:尝试访问ImageMagick时出现“一元运算符后缺少表达式”转换
$convertcmd="convert $dir\tmpI.mpc `(-clone 0 $process `)`(-clone 0 -channel $color2 -separate -threshold $high% $tapering `) -compose over -composite `"$outfile`""
Invoke-Expression -Command $convertcmd
我不断收到
Invoke-Expression : Missing expression after unary operator '-'.
At C:\test\xxxxx.ps1:189 char:21
+ Invoke-Expression <<<< -Command $convertcmd
+ CategoryInfo : ParserError: (-:String) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator,Microsoft.PowerShell.Commands.InvokeExpressionCommand
生成的字符串,$ convertcmd成为
convert .\COLORBALANCE\tmpI.mpc (-clone 0 -channel blue -level 0x98% +channel)(-clone 0 -channel blue -separate -threshold 18.9338%) -compose over -composite /imagemagick/workarea/out/after.jpg
我怀疑它的括号智能感知中的PowerGUI给我在语句的(-clone ...)部分发生了同样的错误,我尝试查找如何转义parens,反斜杠(类似于Unix Shell代码)不起作用,字符也不起作用。
谢谢!这是问题。 – 2013-02-22 20:31:56