#!/usr/local/bin/perl # Export manager # Usage # use lib qw(/export/home/demiurg/dvp/backup/lib); use strict; use File::Basename; use Time::localtime; use dbautil; sub RunExp { # my $day_of_week = substr(ctime(time),0,3); my $log = $dbautil::p->{'export'}->{'log'}; my $file = $dbautil::p->{'export'}->{'file'}; my ($output, $retval); local (*R, *W); # Set enviroment $ENV{'NLS_LANG'} = $dbautil::p->{'export'}->{'nls_lang'}; # Set NLS_LANG # Prepare commands my $before_cmd =$dbautil::p->{'export'}->{'before_cmd'} ; my $post_cmd = $dbautil::p->{'export'}->{'post_cmd'}; my $cmd = $dbautil::ora_home."/bin/exp ". $dbautil::p->{'export'}->{'ologin'}. " file= $file ". $dbautil::p->{'export'}->{$day_of_week}. " log=$log"; # Time to run unless ($dbautil::debug) { print "Before is ".$before_cmd."\n"; } $output = `$before_cmd`; unless ($dbautil::debug) { print "\n Cmd is is ".$cmd."\n"; } ($retval, $output ) = &RunCmd ($cmd, $dbautil::p->{'export'}->{'ok_string'}); if ( $retval ) { h_send_mail ({ 'From' => $dbautil::ora_sid, 'To' =>$dbautil::p->{'dba_mail'} , 'Subject'=> $dbautil::p->{'export'}->{'export_fail'} }, $output); } # Now time to copy file if ( -p $file ) { #if file is pipe $file = $dbautil::p->{'export'}->{'workdir'}."/exp".$dbautil::ora_sid.".dmp"; } cp ($dbautil::p->{'export'}->{'cp'}, $file, basename($file).".".$dbautil::run_date ); # Post export task $output = `$post_cmd`; } ReadConfigFile ($ARGV[0]); RunExp;