« QL: Où s'en va votre argent? | Main | A Special Christmas Box from SNL »

septembre 20, 2006

Bad file descriptor on perl and IIS 6 (Win2003)

Here's a sticky problem that took me quite a while to find out.

I had a perl script that did a qx(something.bat $file); it worked fine on Win2000/IIS5, it worked fine on the command line on Win2003, but on the web site, I would always get a Bad file descriptor error.

So I replaced qx by system, and then I got the error: Can't spawn cmd.exe Then it was easy to figure out that the problem was related to cmd.exe.

The problem was that the IUSR_WEB user did not had the Read/Execute permissions on C:\windows\system32\cmd.exe. Also be sure to put $ENV{'PATH'} = 'C:/windows/system32/;'; on top of your script.

So in case anyone has this problem in the future, that's the way to solve it.

Posted by gfk at septembre 20, 2006 10:55 AM

Comments

Hi there, I am also getting a similar problem but not able to resolve it. I am using Perl 5.8 with Apache 2.2, all configured and working fine. I am able to run perl programs from command prompt. I am also able to call CGI scripts from HTML pages using Apache and it works fine. The problem is with the database connectivity using WIN32::ODBC. Look at the following code: my $DSN = "ABC"; my $connection = new Win32::ODBC($DSN) or die "Could not open connection to DSN because of [$!]"; It works perfectly fine from command prompt. I am even able to fire queries and display the results but the same code gives me "Bad File Descriptor" when run from the website (CGI script called from an HTML page). Have tried so many things but could not get through this. Kindly advise.

Posted by: enjoy_life27 [TypeKey Profile Page] at mars 15, 2007 8:55 AM

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?