Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

running perlscript from shell script

by keralaqueen234 (Initiate)
on May 06, 2013 at 11:02 UTC ( #1032243=perlquestion: print w/replies, xml ) Need Help??
keralaqueen234 has asked for the wisdom of the Perl Monks concerning the following question:

hi ,

i have a requirement wherein i have 3 perlscripts say 1.pl,2.pl and 3.pl. i need to execute these three pearl scripts from inside a shell script, by passing arguments. example would be like , i have a shellscript named shellscript.sh .inside this shell script i have called the 3 perlscripts . So on executing the shellscript (by passing arguments shellscript.sh arg1 arg2, it should execute the 3 perl scrits called inside. these 3 perlscripts also need the passed arguments . in short if i call shellscripts.sh arg1 arg 2, this inturn calls 1.pl arg1 arg2, 2.pl arg1 arg2, 3.pl arg1 arg2 . how to do ths? </p

Replies are listed 'Best First'.
Re: running perlscript from shell script
by choroba (Chancellor) on May 06, 2013 at 11:18 UTC
    This is not a Perl question, it is a shell question. The answer depends on what kind of shell you run; but usually, the following should work:
    1.pl "$@" 2.pl "$@" 3.pl "$@"

    "$@" stands for "all the arguments".

    If only particular arguments are needed, you can use the positional arguments:

    4.pl "$2" # Only the second argument.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: running perlscript from shell script
by zwon (Abbot) on May 06, 2013 at 11:21 UTC
    sh, check the "special parameters" section.
Re: running perlscript from shell script
by Anonymous Monk on May 07, 2013 at 01:21 UTC

    Hi,

    For me the real question is - why are you running a shell script at all?

    And why 3 Perl progs?

    You are passing the same args into all the progs. Why not just pass them into one prog and do all the work of the three progs in one go?

    I would give it a bit more thought.

    J.C.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1032243]
Approved by Corion
help
Chatterbox?
[marioroy]: Today, wanted to revisit running parallel Re: Crash with ForkManager on Windows. I tried running on Cygwin for comparison.
[marioroy]: Running parallel on Cygwin feels like running on Unix ;-)
[marioroy]: Fortunately, Strawberry Perl v5.26 runs well.
[karlgoethebier]: marioroy: He! Magic Mushrooms was a talk in the CB some days ago ;-)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-09-23 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (272 votes). Check out past polls.

    Notices?