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

I have a registering page for a small LAN game I run and the scipt isnt working correctly. I edited the code a little bit becuase I somewhat understand perl.....anyway....after i saved it in windows it doesnt work... I know its not the code becuase this has happened before. My brother fixed it before in linux, I think it had something to do with the way it was saved.... but im not exactly sure any ideas?
  • Comment on perl script not running properly off web server

Replies are listed 'Best First'.
Re: perl script not running properly off web server
by krujos (Curate) on Jul 31, 2002 at 19:37 UTC
    When your brother saved it in Linux it was probably the file permissions. Can you run the code form the command line in windows? If you are editing in windows and putting it back on to the Linux server check the file permissions (ls -l) . They should be -rwxr-xr-x. In windows I think there is a utility called calcs to query/change the access control list of the file. If the web server can’t run it then you need to change that.
    UPDATE: use strict and warnings and CGI harassment...
    Your life, and finding a code problem in this script if it is indeed a code problem would be much easier if you were A. Using strict B. Using warnings and C. using CGI.

      Another possibility, if he is editing the code under Windows and running under Linux (or vice-versa), it to check if the lines are properly delimited. Win/DOS delimiters can confuse the Perl parser under Linux, and I have no idea what the Linux/UNIX delims would do under Windows.

      --rjray

        You can try running dos2unix if you are going windows to linux and see if that helps. It should be a standard tool. if its not you can allways remove them by hand. I beleive they look like ^M at the end of each line.
Re: perl script not running properly off web server
by tomhukins (Curate) on Jul 31, 2002 at 19:39 UTC
    When asking for help, it's a good idea to give as much information as possible. It's a good start that you've posted the code, but you don't describe how it isn't working correctly. What have you done to try to fix it? What do your Web server error logs say? What happens when you use strict and warnings? I suggest you investigate the CGI module which allows you to debug CGI scripts from the command line. Whenever you write code, it's a good idea to check for potential errors throughout the code: this makes it easier to determine the cause of any errors that occur.
Re: perl script not running properly off web server
by elffin (Initiate) on Jul 31, 2002 at 19:29 UTC

      Check out these tutorial pages by pair networks for some background information on running CGI scripts and fixing permissions, errors etc.:

      • http://www.pair.com/pair/support/tutorials/debugperl.html
      • http://www.pair.com/pair/support/tutorials/filepermissions.html
      • http://www.pair.com/pair/support/trouble/scripting.html

      For a windows editor (with Perl syntax highlighting) that allows you to set the newline mode, see

      • http://www.meybohm.de/proton.html
Re: perl script not running properly off web server
by BorgCopyeditor (Friar) on Aug 01, 2002 at 04:35 UTC

    You didn't mention how you got it from your Windows box to the web server. If you FTP'd it using "binary mode" instead of "ASCII mode,"* your script probably wouldn't run at all, but just return a server error.

    *Disclaimer: I don't really know what these mean; I just press the radio buttons. :)

    BCE
    --Your punctuation skills are insufficient!

      Unix, Windows and MacOS use different character sequences for newlines. In "Binary mode", the FTP program will transfer the file as it is -- just what you expect --, whereas in "Ascii mode", it will change the newlines to those of the target system. Unfortunately, this can break binary files (like images) and generally introduces a lot of trouble. Fortunately, Perl usually doesn't have a problem with different newline sequences.

      I recommend editing everything in unix newline mode (perl scripts/modules, HTML files, ...) and upload in "Binary mode" only.