Re: Logger output behavior not wanted

2005-06-27 Thread Dave Gray
On 6/27/05, Pablo Wolter <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have some troubles to figuring out by myself a way to add the output
> of a script that I run by system function in perl into a logger. The
> code I have is:
[snip]
> print LOG "-- $hostName Database backup\n";
> print LOG "-- Database backup started at: $timeStamp\n\n";
> 
> system("$makeBackup >> $errorLogFile"); # this i want on the logger

You can do:

print LOG qx"$makeBackup";

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




Logger output behavior not wanted

2005-06-27 Thread Pablo Wolter
Hi,

I have some troubles to figuring out by myself a way to add the output
of a script that I run by system function in perl into a logger. The
code I have is:



#!/usr/bin/perl

use Fcntl qw( O_RDONLY O_WRONLY O_CREAT );
use IO::File;

$timeStamp=`date '+%m%d%Y:%H%M'`;
chomp($timeStamp);
$hostName=`/bin/uname -n`;
chomp($hostName);
$makeBackup="/home/pwolter/cstools/bin/makeBackup";
$errorCode=0;
$errorLog="/home/pwolter/pablo/tools/bin/geoDbBackup";
chomp($errorLog);

$errorLogFile="$errorLog"."$timeStamp.log"; # This is working perfect !!!
chomp($errorLogFile);

sysopen (LOG,$errorLogFile,O_WRONLY|O_CREAT, 0600)
or die "Cannot write to file $errorLogFile $!\n";

$| = 1;

print LOG "-- $hostName Database backup\n";
print LOG "-- Database backup started at: $timeStamp\n\n";

system("$makeBackup >> $errorLogFile"); # this i want on the logger

sleep 180; # I try this without success

if ( $? != 0 ) {
$errorCode=1;
} else {
$errorCode=0;
}

if ( $errorCode == 1 ) {
print LOG "\n-- Backup process end with errors!\n";
} else {
print LOG "\n-- Backup process end successfully!\n";
$endTimeStamp=`date '+%m%d%Y:%H%M'`;
chomp($endTimeStamp);
print LOG "\n-- Backup process end at: $endTimeStamp\n";
}
---


This is the content of my logger:




-- Database backup
-- Database backup started at: 06272005:1449


-- Backup process end successfully!

-- Backup process end at: 06272005:1453
tabase backup file is:
   /home/pwolter/cstools/dbBackup.2005.06.27.19.49.tar.gz

If this backup file is to be archived somewhere else
create a text file /home/pwolter/cstools/dbBackup.2005.06.27.19.49
In the text file record the location of actual backup file.



And this is what I like this file to be:


--
-- Database backup
-- Database backup started at: 06272005:1449


tabase backup file is:
   /home/pwolter/cstools/dbBackup.2005.06.27.19.49.tar.gz

If this backup file is to be archived somewhere else
create a text file /home/pwolter/cstools/dbBackup.2005.06.27.19.49
In the text file record the location of actual backup file.

-- Backup process end successfully!
-- Backup process end at: 06272005:1453

-

Any help will be good because I'm a litle lost on this

Thanks in advance

Pablo.







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