I'm trying to make small backup script and I'm having a heck of a time getting a system datestamp in the archive name. Here is the code I'm using:
use strict;
my $date = `date +%Y%m%d`;
my $user = 'piper';
my $cmd = "tar -cpszf $user-$date.tar.gz /path/to/public_html/$user";
print `$cmd`;
When I run that code I get the following error:
Try `tar --help' for more information.
sh: .tar.gz: command not found
If I use $user by itself the code runs fine. If I type in the date by hand instead of using a scalar it runs fine. If I declare date like: my $date = '2002-10-13'; and use it in the archive name it works. Why cant I user the system date function to get the date for the archive name?
Regards,
Charlie
Code:
#!/usr/bin/perl -w use strict;
my $date = `date +%Y%m%d`;
my $user = 'piper';
my $cmd = "tar -cpszf $user-$date.tar.gz /path/to/public_html/$user";
print `$cmd`;
When I run that code I get the following error:
Quote:
tar: Cowardly refusing to create an empty archive Try `tar --help' for more information.
sh: .tar.gz: command not found
If I use $user by itself the code runs fine. If I type in the date by hand instead of using a scalar it runs fine. If I declare date like: my $date = '2002-10-13'; and use it in the archive name it works. Why cant I user the system date function to get the date for the archive name?
Regards,
Charlie