moving files from a dir in one machine to a dir in another machines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting moving files from a dir in one machine to a dir in another machines
# 1  
Old 07-27-2010
moving files from a dir in one machine to a dir in another machines

Hi, I am a unix newbie.I need to write a shell script to move my oracle READ WRITE datafiles from one serevr to another. I need to move it from /u01/oradata/W1KK/.. to /u01/oradata/W2KK,
/u02/oradata/W1KK/.. to /u02/oradata/W2KK.

That is, I actaully am moving my datafiles from one database to another.. database W1KK to W2KK .. both of these databases are on different machines. This is what I have now. I get the list of datafiles into a file called
W1KK_dbfiles.txt. After that, I donot know how to use sed or awk to move the files using scp.Can someone please help with this?

Code:
#!/bin/ksh
sqlplus -s "/ as sysdba" <<EOF>W1KK_dbfiles.txt
       set heading off feedback off verify off
        SELECT name FROM v$datafile WHERE ENABLED='READ WRITE';
       exit;
EOF


Last edited by pludi; 07-27-2010 at 08:21 AM.. Reason: code tags, please...
# 2  
Old 07-27-2010
lets just say you are moving files to "/u02/oradata/W2KK" - directory. this system has
Code:
username -  W2KK
hostname - u02
then your sftp will work like this

sftp W2KK@u02
(here ask for password)
cd /u02/oradata/W2KK/ 
put W1KK_dbfiles.txt

this will put W1KK_dbfiles.txt into the directory /u02/oradata/W2KK
# 3  
Old 07-27-2010
Thanks.But that is not what I am looking for. I will be getting the list of READ WRITE files that need to be moved by -

#!/bin/ksh
sqlplus -s "/ as sysdba" <<EOF>W1KK_dbfiles.txt
set heading off feedback off verify off
SELECT name FROM v$datafile WHERE ENABLED='READ WRITE';
exit;
EOF

the database w1kk is on a machine, say m1 and the database w2kk is on another machine, say m2. The directory structures where the datafiles are located are almost the same. On machine m1 it is-
/u01/oradata/w1kk
/u02/oradata/w1kk
/u03/oradata/w1kk
..
..
..

and on machine m2, it is
/u01/oradata/w2kk
/u02/oradata/w2kk
/u03/oradata/w2kk
..
..
..


Once I identify the files that need to be scp-ed, I need to move the file
/u01/oradata/w1kk to /u01/oradata/w2kk
/u02/oradata/w1kk to /u02/oradata/w2kk
/u03/oradata/w1kk to /u03/oradata/w2kk

I tried to use sed to replace the w1kk to w2kk bu it didnt work. I just didn't know how to do it. This is what I tried with sed -

#!/bin/ksh
sqlplus -s "/ as sysdba" <<EOF>W1KK_dbfiles.txt
set heading off feedback off verify off
SELECT name FROM v$datafile WHERE ENABLED='READ WRITE';
exit;
EOF

for i in `cat W1KK_dbfiles.txt`
do
echo $i
echo `sed 's/W1KK/W2KK/g' $i `
done


This is wrong because - it tells me it doesn't identify $i as a file and second, it loops through the W1KK_dbfiles.txt for all the records, instead of using sed to act on each line of the file. I am just lost. Can someone please help?

Last edited by mathews; 07-27-2010 at 02:32 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Assign read write permission to the user for specific dir and it's sub dir and files in AIX

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. I do not want to assign user the same group of that directories too.... (0 Replies)
Discussion started by: blinkingdan
0 Replies

2. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

3. Shell Programming and Scripting

Copy files and subdirs from dir to a new dir

Hello Comunity I am trying to make a bash shell script that it copies files and subdirs(with files) to a new dir. I would like the dest_dir to contain only subdirectories with files not other subdirs inside. it called : cpflatdir src_dir dest_dir Pleaze help me! Thank you in... (2 Replies)
Discussion started by: BTKBaaMMM
2 Replies

4. Shell Programming and Scripting

Need a script to move the files from one dir to other other dir

Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Discussion started by: viswanathkishor
4 Replies

5. UNIX for Dummies Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file Please help me in this regard and many thanks in advance. (3 Replies)
Discussion started by: nmakkena
3 Replies

6. UNIX for Dummies Questions & Answers

get all files under specified dir and zip them, then transfer to another machine

Hi guys, now, I have the following requirement: 1. Get all files under specified directory 2. the files modify date should be specified date 3. zip these files 4. transfer these files to another machine, assume ip, user and password are given. could you pls provide good solution for... (1 Reply)
Discussion started by: crest.boy
1 Replies

7. Shell Programming and Scripting

A script to find dir, delete files in, and then del dir?

Hello!! I have directories from 2008, with files in them. I want to create a script that will find the directoried from 2008 (example directory: drwxr-xr-x 2 isplan users 1024 Nov 21 2008 FILES_112108), delete the files within those directories and then delete the directories... (3 Replies)
Discussion started by: bigben1220
3 Replies

8. Shell Programming and Scripting

moving dir subdir and files

I have created a directory structure and under the directory subdirectories and files are there.I need to move the entire thing to another path.How can i write a script to do that. currently the path of files is as below : /data1/serial/mcycle/archive : under this path differnt sub dir exist ... (6 Replies)
Discussion started by: dr46014
6 Replies

9. Shell Programming and Scripting

need to move files of particular day from one dir to another dir

Hi, I have hundered's of files of the name CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory. So... (3 Replies)
Discussion started by: ss_ss
3 Replies

10. Shell Programming and Scripting

Moving file(s) from dir to dir

Hi, I am fairly new to writing scripts. I am trying to write a script that moves either One or All of the files from one directory to another. I know how to make the actual command to do it, but i don't quite know how to add operators to it, ie -i or -a. I want -i to move one file from... (4 Replies)
Discussion started by: SirJoeh
4 Replies
Login or Register to Ask a Question