perl script for generates a report for backup times


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl script for generates a report for backup times
# 8  
Old 11-11-2010
For an all-Perl solution, you could do something like this -

Code:
#!/usr/bin/perl -w
use File::Find;
sub wanted {
 if (/begin$/){
   # Read "begin" file
   $file = $File::Find::name;
   open (F, "<", $file) or die "Can't open $file for reading: $!";
   while (<F>){if(/^([0-9\/:-]+).*Beginning.*$/){$times = "$1\n"; last}}
   close(F) or die "Can't close $file: $!";
   # Read "end" file
   $file =~ s/begin$/end/;
   open (F, "<", $file) or die "Can't open $file for reading: $!";
   while (<F>){if (/^([0-9\/:-]+).*Finishing.*$/){$times .= "$1\n"; last}}
   close(F) or die "Can't close $file: $!";
   # Write to "times" file
   $file =~ s/end$/times/;
   open (F, ">", $file) or die "Can't open $file for writing: $!";
   print F $times;
   close(F) or die "Can't close $file: $!";
 }
}
$backupdir = "/u01/app/oracle/backup";
find (\&wanted, $backupdir);

Quote:
Originally Posted by prakashdba2010
...for each database there will be 2 log files (*.begin and *.end) and i need to take the timestamp of these 2 files and need to direct to some file
...
Since you haven't mentioned the location of this (third) file, I've assumed it's the same as that of "begin" and "end" files for each database.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script that automatically generates HTML

hi I have a script with HTML code and am currently generating the html page everytime using genWebsite.sh > startPage.html Is it possible to have a loop at the begining of the script to run this command every minute so an updated HTML page is displayed or could someone suggest an alternative... (2 Replies)
Discussion started by: scriptnewbie
2 Replies

2. UNIX for Dummies Questions & Answers

I need perl script on cold backup in Oracle 10 g

Hi , I am new to Perl script.Can u please provide me perl scripts for the following: 1. Perl script on Cold backup in Oracle 10g 2.Perl script on Hot backup in Oracle 10g (0 Replies)
Discussion started by: Niharika Srivas
0 Replies

3. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

4. Shell Programming and Scripting

Print one's place for 1 to N times, ksh Perl whatever?

Hello all, I would like to create a for loop or whatever is quick that will print the one’s place of a number for 1-N times say for example a printed page formatting is 132 characters wide, I would like a single line 123456789012345678901234567890... ...012 That is 132 characters long. I... (11 Replies)
Discussion started by: KmJohnson
11 Replies

5. Shell Programming and Scripting

Help in modifying existing Perl Script to produce report of dupes

Hello, I have a large amount of data with the following structure: Word=Transliterated word I have written a Perl Script (reproduced below) which goes through the full file and identifies all dupes on the right hand side. It creates successfully a new file with two headers: Singletons and Dupes.... (5 Replies)
Discussion started by: gimley
5 Replies

6. Solaris

How to find out the script which generates the file in solaris/unix ?

Hi A file is generated/created/modified during installation (or) execution of a script. vice versa..How to find out which script is responsible for creating/modifying a file. Example:- ....An existing file ( hosts.ulcm ), this file is created or modified by running a script ( may be... (1 Reply)
Discussion started by: frintocf
1 Replies

7. Shell Programming and Scripting

Help with perl mysql backup script

Hi, im trying to make a script that backups mysql databases but apparently I am having trouble with the variables, or simply something I am missing. Would appreciate any help, here is the script #!/usr/bin/perl -w use strict; require File::Spec; #VARIABLES my $databasename =... (4 Replies)
Discussion started by: Fireline
4 Replies

8. UNIX for Advanced & Expert Users

A Program Which Generates a Script Which Kills It

I have a C++ program, running on Fedora Linux, which has to be able to update itself to a new version, which it can obtain from a server. The way I do this is to have it create a shell script which kills it (the parent process), uninstalls it, downloads the new version (actually it does this... (1 Reply)
Discussion started by: BrandonShw
1 Replies

9. Shell Programming and Scripting

backup report script

Hi , Let me know how to write a script that runs a <a backup command> to check the backups of a particular client from the last_night & today' dates and print the out. (2 Replies)
Discussion started by: new2prog
2 Replies
Login or Register to Ask a Question