Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

running /bin/sh perl file.pl

by aknipp (Initiate)
on May 13, 2013 at 23:59 UTC ( #1033379=perlquestion: print w/ replies, xml ) Need Help??
aknipp has asked for the wisdom of the Perl Monks concerning the following question:

Long store short, that is what I am trying to do

Background, I use an app that includes perl, as I go to many places I see it installed all over the place. For my shebang line I can use something like this:

#!/bin/sh eval 'exec `/usr/bin/iwgethome`/iw-perl/bin/iwperl -x -S $0 ${1+"$@"}' +;

(iw-perl is the app's bundled perl)

The issue I have is that there are some embedded XML files with entries like

command="/some/path/to/perl"

and I am trying to put something on a single commandline which could replicate it. Eval is a SH/BASH function and is not picked up.

I thought something like bash `/usr/bin/iwgethome`/iw-perl/bin/iwperl perlfile - which looks promising, but I get an error like this:

iwperl: cannot execute binary file

Which tells me it is picking up the 1st parameter as the script name, but in this case the 1st parameter is perl not the script.

Figure this is a longshot, but hope for some words of wisdom.

Comment on running /bin/sh perl file.pl
Select or Download Code
Re: running /bin/sh perl file.pl (not, run perl)
by Anonymous Monk on May 14, 2013 at 04:48 UTC

    command="/some/path/to/perl"

    This should be command="commandname" or command="command_name_var"

    That way your program defines what perl program to use

    Or, since its some xml file, use XML::Twig (or whatever ) to change which perl gets called

    Or something else entirely , like runtherightperlforgetaboutshellcauseyouhaveperl.pl ...

    But I don't understand your context

Re: running /bin/sh perl file.pl
by kcott (Abbot) on May 14, 2013 at 05:05 UTC

    G'day aknipp,

    "I thought something like bash `/usr/bin/iwgethome`/iw-perl/bin/iwperl perlfile - which looks promising, but I get an error like this:

    iwperl: cannot execute binary file

    Which tells me it is picking up the 1st parameter as the script name, but in this case the 1st parameter is perl not the script."

    Actually, that tells me that perlfile is a binary file which iwperl cannot execute. (What happened to file.pl?)

    I don't have any problem doing (similar to) what you have there if I specify a script:

    $ cat file.pl print "Hello, world!\n"; $ which perl /Users/ken/perl5/perlbrew/perls/perl-5.14.2_WITH_THREADS/bin/perl $ `echo $HOME`/perl5/perlbrew/perls/perl-5.14.2_WITH_THREADS/bin/perl +file.pl Hello, world!

    -- Ken

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2014-08-30 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (292 votes), past polls