springcake has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl script running on Windows 2003 using ActiveState Perl. It connects to a remote SQL database to retrieve data. It works fine when run on the command line, but when I run it from a web browser I get this error "No such file or directory"
my $connection = new Win32::ODBC($DSN); print qq(Content-type: text/html\n\n); if (!$connection) { print "Could not open connection to DSN because of [$!]"; }

I'm guessing that this is due a permissions issues, when I run it from the command line it is running under my own user, but when I run it in a browser it runs under the "web browser" users. I have a similar script running on my server that connects to a local database, and it works fine.
Can you direct me to where I should look to add/change permissions?

This problem is driving me crazy, please can someone help, too many sleepness nights have passed so far!!

Replies are listed 'Best First'.
Re: Connection to SQL not working through web browser
by chromatic (Archbishop) on Sep 23, 2008 at 17:50 UTC
        print "Could not open connection to DSN because of [$!]";

    I see nothing in the Win32::ODBC documentation which suggests that it sets $! on an error, but I do see that it supports an Error() method. Try that instead.

Re: Connection to SQL not working through web browser
by Corion (Patriarch) on Sep 23, 2008 at 13:35 UTC

    I think your problem has little to nothing to do with Perl and everything to do with the platform. I guess that your IIS administrator or system administrator can configure the user properly, but I also expect IIS ODBC permissions to turn up the locations where you need to set the proper permissions.

Re: Connection to SQL not working through web browser
by moritz (Cardinal) on Sep 23, 2008 at 13:58 UTC
    On linux I'd use strace to find out which file actually can't be found, on windows you can try FileMon (formerly from a company named Sysinternals, in the mean time bought be Microsoft, iirc).

    When you know which file can't be found, you might get a clue why this happens.