On Jun 4, Mat Harris said:

>I want to issue the command to the command line, including the values of 
>these vars. I have tried backticking and the system('command here') but 
>they just send the vars as empty strings.

Here's the program:

  #!/usr/bin/perl

  $date = `date +%y%m%e`;
  $backup_dest = "/backup/home/".$date."-monthly";
  $archive_dest = "/backup/home/archives/".$date."-monthly";
  $backup_target = "/home/";
  $level = "0";

  $cmd = "dump -$level -u -A $archive_dest -f $backup_dest -j 9 $backup_target";
  `$cmd`;

The primary problem I see is that $date has a newline at the end of it.
Why?  Because the 'date' command returns a string with a trailing on its
end.  You could do

  chomp($date = `date +%y%m%e`);

Another problem is that the %e format uses a SPACE.  Today's date is
output as

  0206 4

which will screw up your call to dump, I bet.  You should use a
zero-padded format.

However, you don't really need to use the 'date' command.  Perl has
functions you can use:

  my ($day, $mon, $year) = (localtime)[3,4,5];  # perldoc -f localtime
  my $date = sprintf "%02d%02%02d", $year % 100, $mon + 1, $day;
  my $level = 0;
  my $backup_dest = "/backup/home/$date-monthly";
  my $archive_dest = "/backup/home/archives/$date-monthly";
  my $backup_target = "/home/";

Then call `dump ...` however you want.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to