Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Can I get a -S switch that doesn't care about the execute bit?

by DrWhy (Chaplain)
on Aug 22, 2011 at 23:29 UTC ( #921765=perlquestion: print w/ replies, xml ) Need Help??
DrWhy has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on an application system that depends on being able to run scripts where you don't necessarily know exactly where they are. I'd really like to make is so you can just:
perl scriptname.pl arg1 agr2 ... argn
without necessarily knowing ahead of time which directory the script is in. By setting the PATH variable appropriately and putting '-S' in PERL5OPT I can almost get there. The fly in the ointment is that the scripts that can be found and run this way must have the execute bit set on them. Our system doesn't typically set the execute bits on the perl scripts that are a part of it, and I'd rather not introduce this requirement to the existing system.

So I'm seeking the wisdom of the monastery on this. Does anyone know of a way to accomplish this 'script name resolution' capability for scripts that don't have the execute bit set?

NB:  perl -S script_not_executable.pl will find the script, but will then complain that script_not_executable.pl is not executable. Set the execute bit and it works.

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Comment on Can I get a -S switch that doesn't care about the execute bit?
Select or Download Code
Re: Can I get a -S switch that doesn't care about the execute bit?
by Anonymous Monk on Aug 23, 2011 at 02:24 UTC
    These are your options
    • compile your own perl that overrides find_script
    • symlink perl to a shell script that does the searching and finding like perl -S and then invokes perl with full paths
    • install your scripts using Makefile.PL (or Build.PL) , or set the execute bit when you install them
      Hmm... Thanks for the feedback. I don't suppose anyone has thought about creating a pragma module that lets you make modifications to find_script's behavior? Or does that come to early in perl execution to be amenable to modification by a pragma. If it could work of course it would be something that could only be usefully used as a -m/-M argument on the perl command line, I would guess.

      --DrWhy

      "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

        Hmm... Thanks for the feedback. I don't suppose anyone has thought about creating a pragma module that lets you make modifications to find_script's behavior? Or does that come to early in perl execution to be amenable to modification by a pragma. If it could work of course it would be something that could only be usefully used as a -m/-M argument on the perl command line, I would guess.

        There was this one guy, but a rock fell from the sky and crushed him :)

        Hey, my Win32 doesn't croak if there is no execute bit, you can switch to Win32 :D

        No, it doesn't happen too early ... UTSL

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://921765]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-09-16 05:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (156 votes), past polls