There are several methods for executing external commands from Perl.  The 2
most common would be 'system()' and backticks '``'.  You should probably
read the 'perldoc -f system' for detailed info.  The main difference between
backticks and system is where the commands output goes and where the return
value goes.  With system the output is not redirected for you and the return
code goes to $!.  With backticks the output is returned to the program and
the return code goes to $?.

You should probably try 'perldoc -q backtic' to get more info on this whole
topic.  perlfaq8 has this to say.

       What's wrong with using backticks in a void context?

       Strictly speaking, nothing.  Stylistically speaking, it's
       not a good way to write maintainable code because
       backticks have a (potentially humongous) return value, and
       you're ignoring it.  It's may also not be very efficient,
       because you have to read in all the lines of output,
       allocate memory for them, and then throw it away.  Too
       often people are lulled to writing:

           `cp file file.bak`;

       And now they think "Hey, I'll just always use backticks to
       run programs."  Bad idea: backticks are for capturing a
       program's output; the system() function is for running
       programs.

There's more but I wont repost it here.

All this being said, you should probably look into how perl could do most of
these things for you without using the shell.  The 'cd' shell command is
built in with 'chdir'. perldoc -f chdir reads

        chdir EXPR
              Changes the working directory to EXPR,

and the cp stuff is in a module called File::Copy
This is a standard module that you can get at by putting
use File::Copy;

at the top of your script.  Then somewhere you can
copy ("source", "dest") or die "with a useful message: $!\n";

Guess what I'm going to say next?  perldoc File::Find will tell you more.

Good luck,
Peter C.

--SNIP--
Hello all,
  I'm writing a common gateway interface that will call I need to
issue several shell commands.
(cp, cd, and cd .., and maybe others). Any assistance would be
greatly appreciated. How can a call a shell other than bash.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to