Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Answer: How to run a shell script from a Perl program?

( #80173=categorized answer: print w/ replies, xml ) Need Help??

Q&A > programs and processes > How to run a shell script from a Perl program? contributed by snapdragon

The way to do this is to use a systen call to run your script:

system("script.sh");

However I thought that I'd mention a couple of points to go with this.

  1. Don't assume that your shell environment variables will be kept - a shell script that works fine on the command line may not work when run from Perl
  2. Be careful with your directories - try to make sure you're executing from the right place. It's often worthwhile to do a chdir to the right directory in Perl before calling your script. i.e.  chdir "/path/to/script/";

Good luck!

Comment on Answer: How to run a shell script from a Perl program?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2015-07-31 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls