 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
mrosado2
Joined: 09 Aug 2007 Posts: 5 Country: United States |
|
Successful exit code |
|
I am having problem using the successful exit code when running a RMAN backup using Perl script.
The successful exit code is 0 and the script is exiting with code 1. Can you help me?
|
|
Thu Aug 09, 2007 11:28 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
Please describe how you are starting the process and getting the exit code and where are you seeing it as 1. Which version of 24x7 are you running?
|
|
Thu Aug 09, 2007 11:53 am |
|
 |
mrosado2
Joined: 09 Aug 2007 Posts: 5 Country: United States |
|
|
|
This is only part of the Perl script, which is backing up the archives on request.
my $rman_sql = "run ";
$rman_sql .= "{ ";
$rman_sql .= " allocate channel dsk DEVICE TYPE DISK maxpiecesize 1G ; ";
$rman_sql .= " sql 'alter system archive log current' ; ";
$rman_sql .= " backup ";
$rman_sql .= " (archivelog all not backed up since time 'SYSDATE-2' ";
$rman_sql .= " skip inaccessible ";
$rman_sql .= " format '$backupdir/RMAN_%d_".$rpt_date."_s%s_p%p.ARC' ";
$rman_sql .= " tag hot_archive_toDisk) ; ";
$rman_sql .= " backup ";
$rman_sql .= " current controlfile ";
$rman_sql .= " format '$backupdir/RMAN_%d_%I_".$rpt_date."_s%s_p%p.CTL' ";
$rman_sql .= " tag hot_control_toDisk ; ";
$rman_sql .= " release channel dsk ; ";
$rman_sql .= "} ";
$rman_sql .= " ";
I need to put a dependecies and run the next one after a good successful exit code only.
Successful exit code: 0
|
|
Thu Aug 09, 2007 1:46 pm |
|
 |
mrosado2
Joined: 09 Aug 2007 Posts: 5 Country: United States |
|
|
|
Rel 4.1 build 242
|
|
Thu Aug 09, 2007 2:02 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
The exit code is returned by your Perl script, not RMAN script. Can we see the Perl script?
|
|
Thu Aug 09, 2007 2:11 pm |
|
 |
mrosado2
Joined: 09 Aug 2007 Posts: 5 Country: United States |
|
|
|
#===========================================================================
# RMAN HOT ARCHIVES BACKUP Script:
# (use: HOTARCHIVES_ToDSK.pl)
#===========================================================================
use DBI;
use DBD::Oracle;
use IO::Handle;
use Config::INI::Simple;
use Mail::Sender;
#-------------------------------------------------------------------------
# Read the config file.
my $conf = new Config::INI::Simple;
$conf->read ("T:\\Maint_Jobs\\INI\\settings.ini");
my $db_name = $conf->{DBConfig}->{dbname};
my $db_user = $conf->{DBConfig}->{dbuser};
my $db_pass = $conf->{DBConfig}->{dbpass};
my $mail_users = $conf->{DBConfig}->{mailusers};
my $shipname = $conf->{DBConfig}->{shipname};
my $backupdir = $conf->{DBConfig}->{backupdir};
my $backupORADATA = $conf->{DBConfig}->{backupORADATA};
my $emaildomain = $conf->{DBConfig}->{emaildomain};
my $hotfulltodisksender = $conf->{DBConfig}->{hotfulltodisksender};
#-------------------------------------------------------------------------
# Set up some other variables
#Getting the date
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime time;
my $rpt_date = ($mon+1).".".$mday.".".($year + 1900)."_".$hour."_".$min;
my $error_found = 0;
my $output_directory = 'T:\Maint_Jobs\Log';
my $output_file = "$output_directory/HOTARCHIVES_ToDSK$rpt_date.htm";
my $output_file1 = "$output_directory/HOTARCHIVES_ToDSK1$rpt_date.htm";
open(LOG,">$output_file");
open(LOG1,">$output_file1");
while (! -d $output_directory) { # check if there is a directory called ...
print LOG "Sorry, $output_directory does not exists.\n";
exit 1;
}
while (! -d $backupdir) { # check if there is a directory called ...
print LOG "Sorry, $backupdir does not exists.\n";
exit 1;
}
#-------------------------------------------------------------------------
# Set up the Report Title
print LOG "<font>RMAN HOT ARCHIVES BACKUP TO DISK (HOTARCHIVES_ToDSK.pl for $shipname) Date:";
print LOG $mon+1;
print LOG "/".$mday."/";
print LOG $year + 1900;
print LOG " ".$hour."::".$min;
print LOG "<br></font>";
print LOG "<head><title>RMAN HOT ARCHIVES BACKUP TO DISK (HOTARCHIVES_ToDSK.pl for $shipname) Date:";
print LOG $mon+1;
print LOG "/".$mday."/";
print LOG $year + 1900;
print LOG " ".$hour."::".$min;
print LOG "</title></head><body>";
#---------------------------------------------------------------------------
# See if we can delete any old output files
# Remove the oldest, but leave at least three output files.
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Execute the RMAN COMMANDs
#---------------------------------------------------------------------------
#my $rman_cmd = "rman target / > $backupdir.$shipname.$rpt_date ";
my $rman_sql = "run ";
$rman_sql .= "{ ";
$rman_sql .= " allocate channel dsk DEVICE TYPE DISK maxpiecesize 1G ; ";
$rman_sql .= " sql 'alter system archive log current' ; ";
$rman_sql .= " backup ";
$rman_sql .= " (archivelog all not backed up since time 'SYSDATE-2' ";
$rman_sql .= " skip inaccessible ";
$rman_sql .= " format '$backupdir/RMAN_%d_".$rpt_date."_s%s_p%p.ARC' ";
$rman_sql .= " tag hot_archive_toDisk) ; ";
$rman_sql .= " backup ";
$rman_sql .= " current controlfile ";
$rman_sql .= " format '$backupdir/RMAN_%d_%I_".$rpt_date."_s%s_p%p.CTL' ";
$rman_sql .= " tag hot_control_toDisk ; ";
$rman_sql .= " release channel dsk ; ";
$rman_sql .= "} ";
$rman_sql .= " ";
my $rman_cmd = "set ORACLE_SID=$db_name; \n\n";
$rman_cmd = "rman target / ";
print "$rman_cmd\n";
my $rman_bat_file = "$output_directory/ARCHIVES_FULL.bat";
my $rman_crv_file = "$output_directory/ARCHIVES_FULL.crv";
#print $rman_sql."\n";
#print $rman_cmd."\n";
open(BAT,">$rman_bat_file");
open(CRV,">$rman_crv_file");
print LOG $rman_cmd."<br>";
print LOG $rman_sql."<br>";
print CRV $rman_sql;
print BAT $rman_cmd;
system("$rman_cmd cmdfile=$rman_crv_file log $output_file1 ");
system ("del $rman_bat_file");
system ("del $rman_crv_file");
#---------------------------------------------------------------------------
# Check the output file for errors
#---------------------------------------------------------------------------
my $line_cnt = 0;
open(FH1,"<$output_file1");
while ($line = <FH1>) {
@lines = split(/ORA-|ERROR MESSAGE STA/, $line);
$line_cnt++ if (defined $lines[1]);
$last_occur = $line_cnt if (defined $lines[1]);
print LOG $line."<br>";
}
close FH1;
my $sql = "INSERT INTO DBAS.AUDIT_DBADMIN (event_date, sid_name, event_name) ";
$sql .= " values (sysdate, '$db_name', 'HOTARCHIVES_ToDSK') ";
my $db = "DBI:Oracle:".$db_name;
my $db_connection = DBI->connect($db,$db_user,$db_pass) || warn "Database connection not made:$DBI::errstr";
my $sth = $db_connection->prepare($sql);
$sth->execute();
my $sth = $db_connection->prepare("commit");
$sth->execute();
exit 0 if ($line_cnt == 0); ## If we don't have any errors, we should have a
## good backup (so no email is required).
close LOG;
@user = split(/;/,$mail_users);
$cnt = 0;
while (defined $user[$cnt]) {
$sender = new Mail::Sender
{smtp => $emaildomain, from => $hotfulltodisksender};
$sender->MailFile({to => $user[$cnt],
subject => "This is the ARCHIVES RMAN Backup for ship = $shipname",
msg => "This is the ARCHIVES RMAN Backup for ship = $shipname",
file => $output_file});
$cnt++;
}
#system ("del $output_file");
system ("del $output_file1");
|
|
Thu Aug 09, 2007 2:17 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
It looks like something fails within the Perl script, perhaps the last "system" command fails to delete the file.
If you don't care about the exit code, just add to the end of the Perl script exit 0;
|
|
Thu Aug 09, 2007 3:32 pm |
|
 |
mrosado2
Joined: 09 Aug 2007 Posts: 5 Country: United States |
|
|
|
No, I care. If the RMAN command fail I would like to be notify.
|
|
Thu Aug 09, 2007 4:00 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7951
|
|
|
|
In this case, you should check for exit codes of commands executed within the Perl script and at the end of the script make it exit either with a zero (success) or with some other value indicating what kind of error it found. Simple printing to the log is not the same thing.
Please take a look at http://blogs.msdn.com/shamit/archive/2005/02/01/365217.aspx, this may give you some ideas.
|
|
Thu Aug 09, 2007 4:12 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|