I work for a local government agency as the Network Administrator. I wrote this code as part of a backup application that creates tars of all data files to a backup server and then to a removeable drive. This is a web based interfaced to the copy to removeable drive code. I ran into the same problem that is being described, looking at my code may help:
#!/usr/bin/perl # # Initialization use CGI qw(:standard *table); use CGI::Carp qw(fatalsToBrowser set_message); # Mailer to send resulting message back to user. use Mail::Mailer; # Manip to send the date at the time of the request use Date::Manip; use Net::SMTP; # ############################ # Get data from GET & POST # ############################ &parse_form; print "Content-type: text/html\n\n"; print " <head><title>MCSE Backup Adminstratation--Copy to Removeable Disk--Main</title> </head> <body bgcolor=\'#FFFFFF\' text=\'#000000\' link=\'#FF0000\' vlink=\'#800000\'> <h1>MCSE Backup Administration</h1> <h3>Copy to Removeable Disk</h3> <h3>Copy Most Recent Back to Removeable Hard Drive</h3> <font face='Arial' size='2'>"; # Define variables my $emailname = "admin"; my $maildomain = "somedomain.gov"; my $smtp = "mail.somedomain.gov"; open (NEXTDAY,"/home/backup/log/nextday"); open (LOG,">/backup/hdb/results.log"); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime; $year += 1900; ++$mon; $todaysdate = $mon . '/' . $mday . '/' . $year; $todaystime = $hour . ':' . $min . ':' . $sec; @NEXTDAY=<NEXTDAY>; foreach $line(@NEXTDAY){ chomp($line); $todaybackup=$line; } close (NEXDAY); $day[1]="Sunday"; $day[2]="Monday"; $day[3]="Tuesday"; $day[4]="Wednesday"; $day[5]="Thursday"; $day[6]="Friday"; $day[7]="Saturday"; $testday=0; while ($testday < @day) { ++$testday; if ($day[$testday] eq $todaybackup) { $todayday=$testday} } --$todayday; print "Beginning Backup at $todaystime on $todaysdate <br>"; print "Backup day to copy to removeable drive: $day[$todayday] <br>"; print "which is day number $todayday of the week <br>"; print "I will email the results of this proces to $emailto <br>"; print "Note: This process will take at least 40 minutes <br> </body> </html>"; print LOG "Beginning Backup at $todaystime on $todaysdate \n"; print LOG "Backup day to copy to removeable drive: $day[$todayday] \n"; print LOG "which is day number $todayday of the week \n"; print LOG "Removing Old Copy on /dev/hdb \n"; $errors=0; @error1 = system("rm -Rf /backup/hdb/*.tar*") or ++$errors; if ($errors = 0) { print LOG "$archive successfully deleted \n"; } else { foreach $line(@error1){ print LOG "Deleting $archive resulting in error code #$line \n"; } } print LOG "Copying Files . . . . . . . . \n"; ############################ # /backup/hdc/hammerhead/web # ########################### $errors=0; $archive1="/backup/hdc/hammerhead/web/" . $day[$todayday] . ".tar.gz"; @error2 = system("cp $archive1 /backup/hammerhead.web.tar.gz") or ++$errors; if ($errors = 0) { } else { foreach $line(@error2){ print LOG "Copy from Server Hammerhead resulted in error code #$line \n"; } } ############## # End Backups # ############# ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime; $year += 1900; ++$mon; $todaysdate = $mon . '/' . $mday . '/' . $year; $todaystime = $hour . ':' . $min . ':' . $sec; print LOG "Backup completed at $todaystime on $todaysdate \n"; print LOG "######################## \n"; my $date = &UnixDate("today","%e %b %Y %T"); ################################## # Reopen log file and read it in # ################################## open (LOG3,"/backup/hdb/results.log"); @LOG3=<LOG3>; close (LOG3); ###################### # Open email message.# ###################### #print "$emailto"; $me{'To'} = $emailto; $me{'From'} = "administrator\@somedomain.gov"; $me {'Date'} = "$date"; $me {'Subject'} = "Copy Backup to removeable hard drive"; $mailer = new Mail::Mailer 'smtp', Server => "$smtp"; $mailer->open(\%me); ################ # Send Message # ################ foreach $line(@LOG3) { chomp($line); print $mailer "$line\n"; } print $mailer ":\n"; print $mailer "END\n"; $mailer->close; ######################################## # Code to get the data from GET & POST # ######################################## sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if (length($buffer) < 5) { $buffer = $ENV{QUERY_STRING}; ($action,$emailto) = split ("&",$buffer); }else{ $action="email"; @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($field, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $contents{$field} = $value; } $emailto = $contents{'email'}; } } _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs