in reply to Running a shell command via Perl

you can also run them as pipes so you can parse the output.

open (FileHandle,"cp thisFile /root/thatfile|"); @Output = <FileHandle>;

This allows you to see the output of the comand, it is good for error checking with the cp command

Replies are listed 'Best First'.
Re^2: Running a shell command via Perl
by just dave (Acolyte) on Apr 24, 2006 at 06:52 UTC
    Thank you ALL
    I have it working now.
    I also found something else:
    use Shell; my $sh = Shell->new; $tmp = $sh->exec('readlink /root/Desktop/PerlScripting/mylink '); print "$tmp";
    (here I run the "readlink" shell command)
    What is your opinion on this ?
    BTW, although most command work, I can't get the cd command to work (e.g - `cd /root/Desktop/perlTesting/` )
    Why ?
      Regarding the `cd /root/.... you need to use the Perl built-in chdir

      Cheers,

      JohnGG

      When you need to make a call for system resources try to see (or search in portuguese) if similar command are available on builtin funtions...

      $ perldoc -f readlink readlink EXPR readlink Returns the value of a symbolic link, if symbolic links are implemented. If not, gives a fatal error. If there is some system error, returns the undefined value and sets $! (errno). If EXPR is omitted, uses $_.

      This resource is new for me, but my first try is perldoc local or via web. (the second is CPAN! ;)

      --
      Marco Antonio
      Rio-PM