Syntactic Confectionery Delight | |
PerlMonks |
Re: How do you pass arguments from Perl to Powershell?by Util (Priest) |
on Nov 18, 2011 at 17:26 UTC ( [id://938888]=note: print w/replies, xml ) | Need Help?? |
First, basic debugging: Extract that long command string to a separate var, and print it. You will see that you are not passing the string that you think. When you put a $var in single quotes, it does not get replaced with the value of $var (interpolation). Double-quoted strings *do* interpolate. Second, (as Anonymous Monk pointed out), $^X is the wrong thing to pass as second parameter; it would run another copy of Perl, instead of PowerShell. Read the docs, not just example code. The Win32::Process docs say that it is the "full path of the executable module", so in your case, it is probably the full path to PowerShell. When quoting is complex, it helps to build the string in stages, and sometimes to use q{...} and qq{...} in place of '...' and "...". Use 0 instead of DETACHED_PROCESS until everything else is working right, so you can better see the errors from PowerShell. The code below is untested for PowerShell, since I lack it on my Win2k box. I don't know exactly what kind of quoting it expects, or what that & does, but this should get you farther down the path:
In Section
Seekers of Perl Wisdom
|
|