Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Script works differently on two different servers

by Anonymous Monk
on Jul 23, 2009 at 11:49 UTC ( [id://782640] : perlquestion . print w/replies, xml ) Need Help??

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

Dear Monks,
I have a perl-Mechanize script running on my server that works perfectly. It's a very simple script that reads in some POST variables, then grabs one of my blog pages and submits the values in comment form. I have gotten it to work on my server, but I need to put the script now on a different server and am having problems with it.

When I run the script in the command line on the new server (with hard coded values), it works fine. But if I call it as a form 'action' method from a website, the script returns an internal server error. It's the exact same script but it runs differently on two different servers. I checked the versions of all three of the libraries that it uses:


And have updated all of these libraries on the new server so that I now have the latest version of these libs.

Could it be a setting in Apache that is causing the problem? If so, what should I look for? I need to get this to work on my new server and am not sure how to go about solving this.

  • Comment on Script works differently on two different servers

Replies are listed 'Best First'.
Re: Script works differently on two different servers
by moritz (Cardinal) on Jul 23, 2009 at 11:56 UTC
    Instead of wondering blindly what's happening, simply read what Apache has to say about it. There's usually an error.log file containing the error messages, by default in /var/log/apache2/error.log or so.
Re: Script works differently on two different servers
by davorg (Chancellor) on Jul 23, 2009 at 12:36 UTC

    Problems like this will often be down to the ownership of the file or the permissions of the user owning the file. Remember that when running as a CGI program your code almost certainly runs as the web server user, not as you.

    But this is all just guesswork. As moritz says, the only way to be sure is to look in the error log.

    Update: I've just remembered - This is a FAQ.


    See the Copyright notice on my home node.

    Perl training courses

      An added note: you should also check the user name of the server; they may be different on different machines. Some names are: nobody, www, and web.

Re: Script works differently on two different servers
by H4nch0 (Initiate) on Jul 23, 2009 at 18:56 UTC
    I would definitely check the permissions on your scripts. If these are correct, check to make sure you scripts have UNIX line endings. I've had the same issue & I realized that my script had some mixed line endings. Once I modified it to have UNIX only line endings, the script ran on both the command line & in the browser.