Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 pondering the Monastery: (7)
As of 2014-08-23 21:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls