LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2009, 03:12 AM   #1
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Rep: Reputation: 15
script to copy files


Hello shell experts;


I have log-file name alert.log. This log file is updated frequently.

Here is the content:

view alert.log

..
..
..
Media Recovery Log /oracle/archives/arch_1_19_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_20_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_21_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_22_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_23_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_24_691513588.arc
Mon Jul 6 19:54:47 2009
Media Recovery Log /oracle/archives/arch_1_25_691513588.arc
Errors with log /oracle/archives/arch_1_25_691513588.arc
ORA-279 signalled during: ALTER DATABASE RECOVER automatic database using backup controlfile until cancel ...


---------------------------------------------------------------

In another server,I have directory /oracle/archives

$ ls /oracle/archives
arch_1_13_691513588.arc arch_1_17_691513588.arc arch_1_21_691513588.arc
arch_1_14_691513588.arc arch_1_18_691513588.arc arch_1_22_691513588.arc
arch_1_15_691513588.arc arch_1_19_691513588.arc arch_1_23_691513588.arc
arch_1_16_691513588.arc arch_1_20_691513588.arc arch_1_24_691513588.arc
arch_1_25_691513588.arc arch_1_26_691513588.arc arch_1_27_691513588.arc
arch_1_28_691513588.arc arch_1_29_691513588.arc arch_1_30_691513588.arc



What I want to do is, get the last applied number from alert.log which is 25.(Media Recovery Log /oracle/archives/arch_1_25_691513588.arc)
Copy the files from /oracle/archives
from number 25 to greatest number which is 30 to some other directory (/oracle/temp).

How can I write such a script? I gave these numbers as an example.

Thanks in advance

Last edited by scofiled83; 07-06-2009 at 03:19 AM.
 
Old 07-06-2009, 03:35 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
what have you got?
 
Old 07-06-2009, 03:38 AM   #3
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Original Poster
Rep: Reputation: 15
Ghostdog you helped me a lot before, I guess you will again help me in this issue
These numbers will always increment. I dont have any script yet and dont know how to start

Last edited by scofiled83; 07-06-2009 at 03:39 AM.
 
Old 07-06-2009, 03:39 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by scofiled83 View Post
Ghostdog you helped me a lot before, I guess you will again help me in this issue
These numbers will always increment.
no, i most probably will not help you, not if you put in effort. with 63++ posts, i will not assume you are a newbie anymore.
 
Old 07-06-2009, 03:40 AM   #5
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
he means how far have you got on the script so far?

Last edited by micxz; 07-06-2009 at 03:41 AM.
 
Old 07-06-2009, 03:41 AM   #6
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Original Poster
Rep: Reputation: 15
You are right ghostdog, but I havent decided how to start where to start, etc...
If I got somethings I will work on them.
I really aprreciate if you help me in this issue
 
Old 07-06-2009, 04:12 AM   #7
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Mon Jul 6 19:54:47 2009 Media Recovery Log /oracle/archives/arch_1_20_691513588.arc

Assuming the above log line is on one line and the file names don't change except the _20_:

for i in `cat alert.log | awk '{print $9}' | cut -b 25-26`;
do
echo "copying arch_1_"$i"_691513588.arc to /some/where"
done

I'm no expert and this is a rough but also an easy task. Of course you have to fix it up to make the copy actually happen. replacing the echo with your cp command etc. Think you can do it? It's a start'
 
Old 07-06-2009, 04:23 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
logrotate

maybe?

Last edited by bigearsbilly; 07-06-2009 at 04:28 AM.
 
Old 07-06-2009, 05:29 AM   #9
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Original Poster
Rep: Reputation: 15
I can get the last applied number from alert.log.
I am thinking to write this number to a file and rcp this file other server, read this number from file and copy logs from /oracle/archives.

Is there any other suggestion????

Last edited by scofiled83; 07-06-2009 at 03:11 PM.
 
Old 07-06-2009, 08:18 PM   #10
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Sounds like your in the right direction. Post what you got so far and maybe we help further.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need script to copy all files containing a certain string to a directory dc6463 Programming 21 04-18-2013 01:56 PM
Script to copy files defend Linux - Newbie 2 12-11-2008 10:56 AM
how to make a startup script to copy files dgr Linux - Newbie 3 09-26-2007 09:45 PM
bash script to copy files thtr2k Programming 1 02-08-2007 12:03 AM
will this script copy only certain files? verbatim Programming 5 04-28-2005 09:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration