Link to home
Start Free TrialLog in
Avatar of entint
entint

asked on

perl CGI script hangs calling powershell.exe

Please help!  I usually have no issue gathering output from command line using perl with the SYSYEM() or backticks `` and placing the results into variable. That is, until I tried to call the output of powershell.exe. The most basic command:

powershell.exe -command "& echo hello"

The perl script will run fine from the command line, however, running the same script from CGI via web browser fails. If I substitute the powershell command for any standard windows command I will see the output in the browser so it's not a script issue

I have also tried calling from a batch file:
@go = system "C:\\Inetpub\\wwwroot\\manage\\test.bat";

... I don't think this is a perl issue but rather IIS/windows restriction with powershell.exe. Other people have also been experiencing this issue:

http://www.eggheadcafe.com/software/aspnet/31891003/powershell-starts-but-ne.aspx

Any thoughts on this?

Many Thanks
Avatar of Fairlight2cx
Fairlight2cx
Flag of United States of America image

Based on what you pointed to, my suspicion is that your CGI program needs Administrator access in its security properties to be able to execute PowerShell.

You can right-click on the script and change the user and password for that CGI program in the IIS Manager utility.  Technically, you can change cgi-bin in general, but I don't recommend putting Administrator on more than is necessary.

My educated guess is that the IIS default user does not actually have permissions to execute PowerShell.  That could be due to something about PowerShell itself, or it could be due to PowerShell's location, assuming I'm right at all.
Avatar of Meir Rivkin
try giving full path to powershell.
check if cgi has sufficient permissions
ASKER CERTIFIED SOLUTION
Avatar of entint
entint

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial