Using system( ) command to copy files
Quote:
> Hai,
> The task I wish to perform is to get Perl to copy files from one
> location/directories to another.
> I have tried using the command system( ) . The command I issued was
> #! /usr/bin/perl
Always, always, always use -w.
Quote:
> $path = "/home/lfs/public_html"
^
No semicolon? One thing that you can do to catch errors like this is to
run perl with the -c switch. It will check the syntax of your script
for you.
%perl -c -w foo.pl
Quote:
> $filename = "somefilename";
> system( cp $path/$filename /home/httpd/doc/$distinationfilename);
Better check the documentation for system again. The system function
expects a list to be passed to it. Also, where have you defined
$distinationfilename? Using -w will warn you about this.
Quote:
> exit;
> Somehow it just didn't work. It seems to have a multiple of errors > > reproted
You're pretty close to getting this right. I think that with a little
more reading of the docs, you'll have this down with no problem. Also,
the FAQ that came with your distribution of Perl will be of use to you.
You can also access the FAQ at www.perl.com.
Good luck.
--
(Any opinions expressed are my own, not necessarily those of IBM)