Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How can i call the subroutine of the shell script and pass certain parameters to it?

by mkp19901 (Initiate)
on Oct 29, 2013 at 13:14 UTC ( #1060152=perlquestion: print w/ replies, xml ) Need Help??
mkp19901 has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl ### need something like this source file.sh routine; # <-- this is supposed to be part of file.sh which is called # from perl script and some parameter are passed to it

Comment on How can i call the subroutine of the shell script and pass certain parameters to it?
Download Code
Re: How can i call the subroutine of the shell script and pass certain parameters to it?
by Anonymous Monk on Oct 29, 2013 at 13:19 UTC

      Also see do, which would be the closest thing to source in terms of Perl.

      Or maybe Get default login environment, if the objective is "just" to set up some environment.

      Still, defining and then calling shell functions from within Perl requires lots of effort that I'd try to avoid.

Re: How can i call the subroutine of the shell script and pass certain parameters to it?
by hippo (Curate) on Oct 29, 2013 at 13:20 UTC

    Did you try this:

    system ('. file.sh && routine');

    It's untested, but may give you a pointer. However, I advise against the whole principle as it will be somewhat lacking in transparency and therefore maintainability. YMMV.

    It does sound a little like an XY Problem.

Re: How can i call the subroutine of the shell script and pass certain parameters to it?
by builat (Scribe) on Oct 29, 2013 at 17:04 UTC
    If you have some *.sh script with some kind of output good way to do my $ScalarForOutput = `sh MyScript.sh`;
    following this way you take output of MyScript.sh in $ScalarForOutput

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-10-25 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls