For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > November 2007 > Path to Perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Path to Perl
chuck

2007-11-27, 7:10 pm

Hi,

New to Linux and apache and Perl so I appreciate any help i can get.

I have a user who needs to move his perl scripts from his Windows
development machine to our Linux web server. How can I easily change the
path to all the perl scripts that will get transfered over ? Or is there
another alternative such as adding an environment variable for the "apache"
user ?

Thanks


RedGrittyBrick

2007-11-27, 7:10 pm

chuck wrote:
> Hi,
>
> New to Linux and apache and Perl so I appreciate any help i can get.
>
> I have a user who needs to move his perl scripts from his Windows
> development machine to our Linux web server. How can I easily change the
> path to all the perl scripts that will get transfered over ? Or is there
> another alternative such as adding an environment variable for the "apache"
> user ?
>


Your subject says "Path to Perl" but the body says "path to all the perl
scripts". Those are two completely different things. Assuming you mean
the former and are referring to the so-called shebang line:

perl -p -i -e 's|^#!perl|#!/usr/bin/perl| if $.==1;' *.pl


Presumably the user used no unusual modules and didn't make explicit
references to platform specific filesystem locations ("c:\") etc etc.
RedGrittyBrick

2007-11-27, 7:10 pm

chuck wrote:
> Or is there
> another alternative such as adding an environment variable for the "apache"
> user ?


Oops yes, IIRC the apache config file specifies what happens when
someone requests a URL that points to a .pl or .cgi file.

I'd be surprised if your apache service wasn't already configured for
this but YMMV.
chuck

2007-11-27, 7:10 pm

What I need to do is change the first line of all the scripts from
"c:/perl/..." to "#!usr/bin/perl"

or get the system into look in /usr/bin/perl without changing the scripts by
using an environment variable.




"RedGrittyBrick" <RedGrittyBrick@SpamWeary.foo> wrote in message
news:474c2dc4$0$8423$db0fefd9@news.zen.co.uk...
> chuck wrote:
>
> Your subject says "Path to Perl" but the body says "path to all the perl
> scripts". Those are two completely different things. Assuming you mean the
> former and are referring to the so-called shebang line:
>
> perl -p -i -e 's|^#!perl|#!/usr/bin/perl| if $.==1;' *.pl
>
>
> Presumably the user used no unusual modules and didn't make explicit
> references to platform specific filesystem locations ("c:\") etc etc.



Sherman Pendley

2007-11-27, 7:10 pm

"chuck" <chuck@no.where> writes:

> New to Linux and apache and Perl so I appreciate any help i can get.
>
> I have a user who needs to move his perl scripts from his Windows
> development machine to our Linux web server. How can I easily change the
> path to all the perl scripts that will get transfered over ? Or is there
> another alternative such as adding an environment variable for the "apache"
> user ?


Just use "#!/usr/bin/perl" - Windows uses its file-type associations to find
the Perl binary anyway, so it won't care.

sherm--

--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Gunnar Hjalmarsson

2007-11-27, 7:10 pm

Sherman Pendley wrote:
> "chuck" <chuck@no.where> writes:

Sounds like CGI scripts to me ...
[color=darkred]
> Just use "#!/usr/bin/perl" - Windows uses its file-type associations to find
> the Perl binary anyway, so it won't care.


.... and if so, that's not true. CGI scripts need the correct path to
perl also on Windows.

OTOH, personally I have a symlink in C:/usr that points to the directory
with perl.exe, and that directory is conveniently named 'bin'.
Consequently, #!/usr/bin/perl works just fine for my CGI scripts on Windows.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
RedGrittyBrick

2007-11-27, 7:10 pm

chuck wrote:

<top-posting corrected - pleas don't do that>

>
> "RedGrittyBrick" <RedGrittyBrick@SpamWeary.foo> wrote in message
> news:474c2dc4$0$8423$db0fefd9@news.zen.co.uk...
>
>
> What I need to do is change the first line of all the scripts from
> "c:/perl/..." to "#!usr/bin/perl"


perl -p -i.bak -e 's|^\S+|#!/usr/bin/perl| if $.==1;' *.pl

Untested. Should retain flags (e.g. #!c:/perl/bin/perl.exe -w).
Assumes the old (Windows) path to perl contains no spaces.
Keeps a copy of original versions of scripts with filename suffix ".bak".

You could also use awk sed or some similar tool that you are more
familiar with. I guess you are not familiar with these since you asked
the question. Which suggests you are not very familiar with Unix/Linux.
If so, do above when logged in as ordinary user (not root), I'd put
files in a newly created directory before working on them.

>
> or get the system into look in /usr/bin/perl without changing the
> scripts by using an environment variable.
>


I'd configure Apache, forget environment variables.


chuck

2007-11-27, 7:10 pm


"RedGrittyBrick" <RedGrittyBrick@SpamWeary.foo> wrote in message
news:474c569c$0$21095$da0feed9@news.zen.co.uk...
> chuck wrote:
>
> <top-posting corrected - pleas don't do that>
>
>
> perl -p -i.bak -e 's|^\S+|#!/usr/bin/perl| if $.==1;' *.pl
>
> Untested. Should retain flags (e.g. #!c:/perl/bin/perl.exe -w).
> Assumes the old (Windows) path to perl contains no spaces.
> Keeps a copy of original versions of scripts with filename suffix ".bak".
>
> You could also use awk sed or some similar tool that you are more
> familiar with. I guess you are not familiar with these since you asked
> the question. Which suggests you are not very familiar with Unix/Linux.
> If so, do above when logged in as ordinary user (not root), I'd put
> files in a newly created directory before working on them.
>
>
> I'd configure Apache, forget environment variables.
>
>


Thanks. Ended up using sed, after figuring out the escape characters that
is.



Gretch

2007-11-27, 7:10 pm

In news:fihcco$eqf$1@nrc-news.nrc.ca,
chuck <chuck@no.where> wrote:

> What I need to do is change the first line of all the scripts from
> "c:/perl/..." to "#!usr/bin/perl"


Please don't top-post.

The relative path "usr/bin/perl" isn't what you want to do. You'll have
better portability with

#!/usr/bin/env perl

Thrill5

2007-11-27, 7:10 pm


"chuck" <chuck@no.where> wrote in message
news:fiha0p$ddc$1@nrc-news.nrc.ca...
> Hi,
>
> New to Linux and apache and Perl so I appreciate any help i can get.
>
> I have a user who needs to move his perl scripts from his Windows
> development machine to our Linux web server. How can I easily change the
> path to all the perl scripts that will get transfered over ? Or is there
> another alternative such as adding an environment variable for the
> "apache" user ?
>
> Thanks
>

My question would be why is he using a shebang for the perl path on a
windows machine in the first place?


Ron Bergin

2007-11-28, 4:16 am

On Nov 27, 9:01 am, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Sherman Pendley wrote:
>
>
> Sounds like CGI scripts to me ...
>
>
> ... and if so, that's not true. CGI scripts need the correct path to
> perl also on Windows.
>
> --


Sorry Gunnar, but that's not true. apache can be configured to use
the Windows registry to locate perl instead of using the shebang
line. Here's the required config line.

ScriptInterpreterSource registry

http://httpd.apache.org/docs/1.3/mo...terpretersource
Gunnar Hjalmarsson

2007-11-28, 4:16 am

Ron Bergin wrote:
> On Nov 27, 9:01 am, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>
> Sorry Gunnar, but that's not true. apache can be configured to use
> the Windows registry to locate perl instead of using the shebang
> line. Here's the required config line.
>
> ScriptInterpreterSource registry
>
> http://httpd.apache.org/docs/1.3/mo...terpretersource


Thanks for the correction; that directive was new to me.

TMTOWTDI

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
A. Sinan Unur

2007-11-28, 8:04 am

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in
news:5r30ncF12m0fuU1@mid.individual.net:

> Sherman Pendley wrote:
>
> Sounds like CGI scripts to me ...
>
>
> ... and if so, that's not true. CGI scripts need the correct path to
> perl also on Windows.


Not really.

http://httpd.apache.org/docs/2.2/mo...terpretersource

Use that option, and you rarely have to tinker with shebang lines.

Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>

Eric Schwartz

2007-11-28, 7:07 pm

"Thrill5" <nospam@somewhere.com> writes:
> My question would be why is he using a shebang for the perl path on a
> windows machine in the first place?


To pass along command line flags like -T?

-=Eric
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com