--------------------------------------------
#!/usr/bin/perl -w
use strict; use File::Copy;
copy("/Users/xxxxxx/Documents/db1.txt", "/Users/xxxxxx/Documents/db1.txt.bak") or warn "Can't copy file: $!";
print "Backup Completed.";
exit;
---------------------------------------------
I know the cron is firing off the request, because when first tried it, I got Permission Denied in my email box. So I changed the permission to 755 and it still doesn't copy the file. And I get nothing in my email box. I'm a little confused. What am I missing?
Mark
On Apr 27, 2004, at 1:31 PM, Ken Williams wrote:
On Apr 27, 2004, at 11:59 AM, Wiggins d Anconia wrote:The script is as follows:
#!/usr/bin/perl -w
use strict;
my @files = "db1.txt, db2.txt, db3.txt, db4.txt";
foreach (@files) { rename "/path/to/pc/file/$_", "/Users/xxxx/Documents/$_".".bak";
You should always check that 'rename' succeeded (as apparently it isn't).
rename $oldfile, $newfile or warn "Can't rename file: $!";
$! will then provide you more information as to why its not working.
I'd be willing to bet that it will be because there's no file called
"/path/to/pc/file/db1.txt, db2.txt, db3.txt, db4.txt"
on your system. Perhaps you mean:
my @files = ("db1.txt", "db2.txt", "db3.txt", "db4.txt");
or just
my @files = qw(db1.txt db2.txt db3.txt db4.txt);
Anyway, Wiggins is right - if you'd checked the error status, $! would have told you...
-Ken