Using system( ) command to copy files 
Author Message
 Using system( ) command to copy files

Well I rewrote your code and this seems to work:

#!/usr/bin/perl
$path = '/home/lfs/public_html';
$filename = 'somefilename';
system("cp $path/$filename  /home/httpd/doc/$distinationfilename");
exit;

Darren



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
>$path = "/home/lfs/public_html"
>$filename = "somefilename";
>system( cp $path/$filename  /home/httpd/doc/$distinationfilename);
>exit;

>Somehow it just didn't work. It seems to have a multiple of errors reproted

>Can someone please suggest to me how can this be done.

>Thank you very much.

>From : Liew



Tue, 17 Apr 2001 03:00:00 GMT  
 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)



Tue, 17 Apr 2001 03:00:00 GMT  
 Using system( ) command to copy files
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
$path = "/home/lfs/public_html"
$filename = "somefilename";
system( cp $path/$filename  /home/httpd/doc/$distinationfilename);
exit;

Somehow it just didn't work. It seems to have a multiple of errors reproted

Can someone please suggest to me how can this be done.

Thank you very much.

From : Liew



Wed, 18 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using File::Copy and Sockets to copy public files from http addresses

2. How to copy files using system( ) in a Perl script

3. Using system() to copy strange files

4. Warning using copy from File::Copy

5. unwanted UNIX file permissions after using File::Copy::syscopy

6. File::Copy, copying files problem.

7. NT/ActivePerl/File::Copy/Network Drive/AT command = unsuccessful

8. Copy file command.

9. problem with "system" and file copy

10. Help: Copy Files in Perl or -i Command Line Switch

11. using here document in perl's system command

12. Variable not used in system command

 

 
Powered by phpBB® Forum Software