Path to Perl

Path to Perl

am 27.11.2007 15:36:09 von Chuck

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

Re: Path to Perl

am 27.11.2007 15:46:25 von RedGrittyBrick

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.

Re: Path to Perl

am 27.11.2007 15:51:07 von RedGrittyBrick

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.

Re: Path to Perl

am 27.11.2007 16:16:40 von Chuck

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" wrote in message
news:474c2dc4$0$8423$db0fefd9@news.zen.co.uk...
> 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.

Re: Path to Perl

am 27.11.2007 17:39:44 von Sherm Pendley

"chuck" 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

Re: Path to Perl

am 27.11.2007 18:01:24 von Gunnar Hjalmarsson

Sherman Pendley wrote:
> "chuck" writes:
>>
>> from his Windows development machine to our Linux web server.

Sounds like CGI scripts to me ...

> 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

Re: Path to Perl

am 27.11.2007 18:40:41 von RedGrittyBrick

chuck wrote:



>
> "RedGrittyBrick" wrote in message
> news:474c2dc4$0$8423$db0fefd9@news.zen.co.uk...
>> 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.
>
>
> 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.

Re: Path to Perl

am 27.11.2007 19:39:49 von Chuck

"RedGrittyBrick" wrote in message
news:474c569c$0$21095$da0feed9@news.zen.co.uk...
> chuck wrote:
>
>
>
>>
>> "RedGrittyBrick" wrote in message
>> news:474c2dc4$0$8423$db0fefd9@news.zen.co.uk...
>>> 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.
>>
>>
>> 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.
>
>

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

Re: Path to Perl

am 27.11.2007 19:50:01 von Gretch

In news:fihcco$eqf$1@nrc-news.nrc.ca,
chuck 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

Re: Path to Perl

am 28.11.2007 01:23:46 von Thrill5

"chuck" 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?

Re: Path to Perl

am 28.11.2007 10:10:48 von Gunnar Hjalmarsson

Ron Bergin wrote:
> On Nov 27, 9:01 am, Gunnar Hjalmarsson wrote:
>> 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/mod/core.html#scriptinterpr etersource

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

TMTOWTDI

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

Re: Path to Perl

am 28.11.2007 14:50:28 von 1usa

Gunnar Hjalmarsson wrote in
news:5r30ncF12m0fuU1@mid.individual.net:

> Sherman Pendley wrote:
>> "chuck" writes:
>>>
>>> from his Windows development machine to our Linux web server.
>
> Sounds like CGI scripts to me ...
>
>> 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.

Not really.

http://httpd.apache.org/docs/2.2/mod/core.html#scriptinterpr etersource

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:

Re: Path to Perl

am 28.11.2007 21:03:26 von Eric Schwartz

"Thrill5" 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