If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > script to copy files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-30-11, 05:48
rakkab007 rakkab007 is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
script to copy files

Hi,

Requirement:-

I have on PRD server and DEV server.I need to copy files from one directory in PRD to DEV directory.Before copying files from PRD to DEV,it has to check any files existing in DEV directory,if existing need to delete that files and then copy files from PRD.

Please help to create one script to do the same..


thanks
Reply With Quote
  #2 (permalink)  
Old 08-30-11, 06:51
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
You haven't said how you want to copy the files. Using 'ftp', 'rcp', 'scp', or 'nfs'?
Files existing in the target (DEV) directory that have the same name as a file in the source (PRD) directory will be automatically replaced, so I don't see the need to delete them first.
Reply With Quote
  #3 (permalink)  
Old 08-30-11, 07:05
rakkab007 rakkab007 is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
here using SCP to copy files....and all the times,copying files are not same...thats why need to delete the existing files whatever it may be from DEV and copy fresh files...supppose in DEV directory it contains 15 files already and planning to copy 13 files from PRD...so need to delete all the files in DEV direcrtory first...
Reply With Quote
  #4 (permalink)  
Old 08-30-11, 07:14
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
On the DEV machine:
Code:
cd where_the_files_are
rm *
scp PRD:/where_prod_files_are/* .

Last edited by kitaman; 08-30-11 at 07:15. Reason: typo
Reply With Quote
  #5 (permalink)  
Old 08-30-11, 08:12
rakkab007 rakkab007 is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
Thanks...another one please....
************************************************** **********************
$ grep "sequence" <filename>.trc | sort -n
************************************************** *************************

Need to execute this command(grep "sequence" <filename>.trc | sort -n) in shell script
and the output is like this

input archive log thread=1 sequence=55159 recid=55252 stamp=760234580
input archive log thread=1 sequence=55160 recid=55253 stamp=760277712
input archive log thread=1 sequence=55161 recid=55254 stamp=760305926
input archive log thread=1 sequence=55162 recid=55255 stamp=760306394
input archive log thread=1 sequence=55163 recid=55256 stamp=760306416
input archive log thread=1 sequence=55164 recid=55257 stamp=760306438
input archive log thread=1 sequence=55165 recid=55258 stamp=760306460
input archive log thread=1 sequence=55166 recid=55259 stamp=760306558..

so after that need to take the highest seq number and some seq number :say 10 less than highest...these two values has to place in the below code during the process..while issuing the below command in script,it has to take these two values and execute ..so how its possible...

restore archivelog low sequence 55162 high sequence 55166;
Reply With Quote
  #6 (permalink)  
Old 08-30-11, 08:39
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Since the output of the grep command is fixed format, you don't need to do a numeric sort.
Use 'tail' to save only the last 10 lines of the sorted output, then the low sequence is the first entry of the output file, and the high sequence is the last.
Code:
grep sequence input.trc |sort |tail -10 >temp.data
#get low sequence number
low=`head -1 temp.data |cut -c37-41`
high=`tail -1 temp.data|cut -c37-41`
restore archivelog low sequence $low high sequence $high
Reply With Quote
  #7 (permalink)  
Old 08-31-11, 06:25
rakkab007 rakkab007 is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
Thanks for the help....


select name from v$datafile;
select name from v$controlfile;
select name from v$tempfile;
select MEMBER from v$logfile;

These sqls has to run in the script and o/p of each sql has to write in seperate files.But the o/p is like if we issue
select name from v$datafile; o/p like
/path/datafilename1
/path/datafilename2
-------------------
So need to change the o/p as
rm -rf /path/datafilename1
rm -rf /path/datafilename2
like that all sql o/p has to come like this and write in seperate files,so that i have to execute that files only

please help to do this...
Reply With Quote
  #8 (permalink)  
Old 08-31-11, 06:43
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Several points:
You should start a new thread for each question.
We are here to help you solve your problem, not do your job for you; when you ask for help, post what you have already done.
Reply With Quote
  #9 (permalink)  
Old 08-31-11, 07:40
rakkab007 rakkab007 is offline
Registered User
 
Join Date: Aug 2011
Posts: 11
ok..i understand....this is the first time am posting in one blog..and moreover am not a shell programmer....only some basic ideas....thats why asked questions like this...excuse it...i will post a new thread for the same...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On