Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2011
    Posts
    11

    Unanswered: 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

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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.

  3. #3
    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...

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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 08:15. Reason: typo

  5. #5
    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;

  6. #6
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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

  7. #7
    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...

  8. #8
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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.

  9. #9
    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •