use File::Path; use IPC::Run qw( run ); my($ORAHOME,$ORASID,$CONNECTUSER); $BACKUPDIR = undef; $LOGDIR = undef; $LOGFILE = '\export_samsdb.log'; # :::::::::::::::::::: End Declare Variables Section # :::::::::::::::::::: Begin Parameter Checking Section Start: print "\n What is the Oracle Home path ?"; chomp($ORAHOME = ); print "What is the Oracle SID ?"; chomp($ORASID = ); print "What is the username\/password ?"; chomp($CONNECTUSER = ); if ($ORASID) { # Create backup directories if already not exist unless (-d $BACKUPDIR) { print "Attempting to make BACKUP directory $BACKUPDIR ...... \n";} eval { (mkpath ($BACKUPDIR='C:\SAMS_DB_BKUP\EXPORT'))}; if ($@) { print "Could not create BACKUP directory: $@ \n"; } else { print "Directory made.\n";} unless (-d $LOGDIR) { print "Attempting to make LOG directory ........ \n";} eval { (mkpath ($LOGDIR='C:\SAMS_DB_BKUP\EXPORT\LOG'))}; if ($@) { print "Could not create LOG directory: $@ \n"; } else { print "Directory made.\n";} # :::::::::::::::::::: Begin Export Section print $ORAHOME . '\\exp ' $CONNECTUSER . '@samsdb full=Y file=' . $BACKUPDIR ' \samsdb.dmp log=' . $LOGFILE; run $ORAHOME . '\\exp ' $CONNECTUSER . '@samsdb full=Y file=' . $BACKUPDIR ' \samsdb.dmp log=' . $LOGFILE; open (loghandle, ">>" .$LOGDIR . $LOGFILE) or die "Cannot create log file"; print (loghandle "Export Completed Successfully"); close(loghandle); } else {print '***********Did not define the Oracle SID'; Goto Start;} # :::::::::::::::::::: End Export Section