Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Dealing with incorrect shebang line entries on Windows with Apache

by tohann (Sexton)
on May 04, 2005 at 15:41 UTC ( [id://453996]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,

I'm running Bugzilla on an Apache Linux server here at work. We want to do some customization of the product to better suit our needs. I have everything set up in CVS and it's running on the server and all is well. Now, when I check it out of CVS and start working on it locally (on a WinNT machine), all of the #! lines are pointing to the server's version of Perl (/usr/local/bin/perl). This of course doesn't exist locally. My question is this, what is the best practice for dealing with this situation? I'm sure lots of people have run into this and I'm curious as to the solutions. The only solutions I could come up with are:

- Manually change each Perl script's #! line (which amounts to 12-15 scripts). And then remember to change them back when versioning.
- Create Ant check-out and check-in scripts that will modify each Perl file and change accordingly.
- Create the /usr/local/bin/perl directory on local machines.

I like the Ant scripts option the best of these three, but am wondering if there's something better out there.

I'm open to all ideas!
Thanks!
Trent

Retitled by Steve_p from 'Best Practices Question...'.

  • Comment on Dealing with incorrect shebang line entries on Windows with Apache

Replies are listed 'Best First'.
Re: Dealing with incorrect shebang line entries on Windows with Apache
by xorl (Deacon) on May 04, 2005 at 15:44 UTC
    You could do:
    ln -s /usr/bin/perl /usr/local/bin/perl

    Update: I'd also point out that development boxes should be exactly the same as the production box. Otherwise you get horrible problems like you're having

      Thank you for your reply. Yes, that would work, but I was hoping for something we would do locally and not have to change the server. I agree, the dev boxes should be the same as production, but that's not going to fly around here in a long, long time. I forgot to mention that we're developing on WinNT and the server is on a Linux machine. That's one more wrinkle. :) I'll modify the original post to state this important fact.

      Trent

        You're using WinNT... Are you using ActiveState's Perl? It ignores the path in the #! line.

        Update: On second thought, the web server on your dev station might pay attention to it. Is there anyway you could tell your web server to use a specific Perl instead of looking at the #! line?

Re: Dealing with incorrect shebang line entries on Windows with Apache
by dave0 (Friar) on May 04, 2005 at 16:00 UTC
    The best idea is to ensure that your development environments are identical in configuration to your production server.

    Your dev systems might have a few extra debugging tools, a nicer text editor, etc, but you'll run into far fewer issues if you at least keep your Perl installations identical.

      Is that common, though? Installing Perl on a WinNT machine into /usr/bin/perl or whatever *nix path structure? I know there's nothing preventing it, I'm just wondering what the best practice is.
        No idea... all my Perl work has been in *NIX environments. Since you suggested that creating /usr/local/bin/perl locally was an option you had considered, I just assumed that your dev environment was also UNIX-like.

        If you're dealing with multiple OS'es, it might be easiest to have your check-in and check-out scripts insert the correct path for that system, or to have your Makefile.PL do it for you as gellyfish suggested.

        Nope.
        By *default* on unix, there is some version of perl in /usr/bin/perl. Generally a newer version of perl is a /usr/local/bin/perl or /home/zaz/my_perl. On windows, generally active state perl is installed at c:\perl\bin\perl , but cygwin installs perl at c:\cygwin\usr\bin\perl, which, if you are using cygwin's apache, you would call perl by /usr/bin/perl . If you use Oracle, you can use the oracle version of perl (not really recommended) at a path (similar to) /u01/oracle/some/version/export/bin/perl .
        As far as development systems being different than production systems, in general, they almost are *always* different. Generally, older systems are used as development boxes, since they don't need the speed of production servers. (Also accept *slower* boxes, since there are times when you can't control the production environment, especially when you don't have root on the box.)
        BTW. 300th post. :-)


        ----
        Zak - the office
Re: Dealing with incorrect shebang line entries on Windows with Apache
by tlm (Prior) on May 04, 2005 at 16:03 UTC

    perlrun recommends

    #!/usr/bin/env perl
    which may work for you in this case.

    Update Added emphasis to the word "may" in response to merlyn's comment. :-)

    the lowliest monk

      That's actually a dangerous practice, if you have multiple installs of Perl. Your PATH may not match my PATH, so we'll end up picking different Perl versions to run.

      Also, env may not be on your box, and worse, I've seen machines where it's /bin/env instead of /usr/bin/env. Ooops!

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Good point. Being the main 'Perl guy' here at work, I have three installs of Perl. A couple others have two installs and the rest have just one install.
Re: Dealing with incorrect shebang line entries on Windows with Apache
by gellyfish (Monsignor) on May 04, 2005 at 16:05 UTC

    You could create a Makefile.PL that specifies the programs you want to install in EXE_FILES (you will also need to specify the correct location to install), this way the shebang will be changed to point to the perl that was used to run the Makefile.PL. See ExtUtils::MakeMaker for more details.

    /J\

      So, in this instance, I would run the Makefile.PL after bringing all the code down to my local machine from CVS, and then again on the server after the changes and checking it back in to CVS?
Re: Dealing with incorrect shebang line entries on Windows with Apache
by artist (Parson) on May 04, 2005 at 17:43 UTC
    Just copy perl.exe to c:/usr/local/bin/perl.exe and it works without any problem.
    --Artist
      dude... On your Win32 platform, why dont you bind .pl extension to your perl.exe ??? 1. Right click a .pl file 2. Open With, Choose program 3. Browse for perl.exe and voila ! i always use the standard #!/usr/bin/perl shebang line with win32 and never had any problems.
        It's required for Apache Web Server.
        --Artist
Re: Dealing with incorrect shebang line entries on Windows with Apache
by barbie (Deacon) on May 06, 2005 at 10:55 UTC
    Why not use the Apache directive that was exactly built for this. Look for:

    ScriptInterpreterSource registry

    in the httpd.conf file, and uncomment it. Hey presto, Apache reads the registry setting for the location of your perl interpreter :)

    --
    Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/

Re: Dealing with incorrect shebang line entries on Windows with Apache
by tohann (Sexton) on May 17, 2005 at 14:44 UTC
    Thank you all for your suggestions. I've decided to go with the Apache configuration option. In order to do that I also had to associate .cgi file types with the Perl executable (.pl was already there), but that's minor. I was rocking after the conf file change and adding that association. Now it works like a champ and won't need a single change when moving code to and fro.

    Thanks for your help!
    Trent

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://453996]
Approved by xorl
Front-paged by tlm
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-23 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found