How to copy files using system( ) in a Perl script
: I need to copy a file from a particular location to another location using
: a cgi written in Perl.
: I have tried the following command but it didn't work
: #! /usr/bin/perl
: $filename = "/path/some_filename";
: $destination_filename = "/path/another_filename"
: system (cp $filename $destination_filename);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1) you are either missing some quotes there, or using
a bareword and missing some commas...
2) check the return value from system()
3) ensure that you have permission for whatever the current
directory is
4) use -w
5) find out where your server error logs are, and see if
there is output there
if (system "cp $filename $destination_filename")
{die "could not copy $!"}
--
Tad McClellan SGML Consulting
Fort Worth, Texas