Copy of file and arborescence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy of file and arborescence
# 1  
Old 04-07-2010
Data Copy of file and tree

Hello has all and thank you in advance this time for help,

I explain you my probleme:
I have two machines: machine A: AIX and machine B: Linux RedHat

On the machine A, I have a serie of file under some tree to inform in a filename.list file

Ex:
/home/dir1/dir2/dir3/dir4/dir5/file1.sh
/home/dir1/dir2/dir6/dir6/dir8/file2.sh

I need to copy files lists in my filename.list file on my machine B by reproducing the tree of the machine A.

In the example, there is only two file has to set, but in my case it is more 300. Smilie

I had think has to make a cat filename.list may use tar and finally scp then again tar on the target machine but how imbricate some with the others Smilie

Thank you in advance for your reponses

Last edited by Sytema; 04-07-2010 at 11:06 AM.. Reason: arborescence == tree
# 2  
Old 04-07-2010
Bonjour!

While this site provides an translation service for non-english speaking visitors, all posts have to be in english. Please repost.

---------- Post updated at 15:37 ---------- Previous update was at 14:53 ----------

Do you need just the files? Then create a listing using find, loop over that list & create the files using mkdir and touch.
Do you need to copy over the files just once? Use tar + ssh.
Do you need to keep the 2 trees synchronized? Use rsync.

Example for the one-shot copy:
Code:
cd /home/dir1/dir2 ; tar -cf - . | ssh target 'cd /home/dir1/dir2 ; tar -xf -'

# 3  
Old 04-07-2010
Hello, thanks for your help,

But i need on the same shell :
- create the same tree on machine A & B
- copy files on the same place (because files are launch by scheduler)
- i don't need all files on machine A, that's why i have create filename.list

I try this but it's not working
Code:
cat filename.list | while read FILENAME; do tar -cf - $FILENAME | ssh target 'cd / ; tar -xf -';done

I have this error message :
Quote:
root@target's password:
tar: Retrait de « / » de tęte des noms des membres
Usage: tar -{c|r|t|u|x} [ -BdDEFhilmopRsUvw ] [ -Number ] [ -f TarFile ]
[ -b Blocks ] [ -S [ Feet ] | [ Feet@Density ] | [ Blocksb ] ]
[ -L InputList ] [-X ExcludeFile] [ -N Blocks ] [ -C Directory ] File ...
Usage: tar {c|r|t|u|x} [ bBdDEfFhilLXmNopRsSUvw[0-9] ]
[ Blocks ] [ TarFile ] [ InputList ] [ ExcludeFile ]
[ [ Feet ] | [ Feet@Density ] | [ Blocksb ] ] [-C Directory ] File ...
root@target's password:
All files and tree are correctly create on target machine but the owner and the right of file and directory is not ok

Last edited by Sytema; 04-07-2010 at 12:46 PM..
# 4  
Old 04-07-2010
Why not use rsync with a '--include merge' option using a list of files to include in the transfer. (type "man rsync" to get all the options, there's certainly one that match your needs).
# 5  
Old 04-07-2010
First off, you get a Useless Use of Cat Award.

Second, you don't need to run tar once for each individual file; assuming a small number of files, you can do this:

Code:
# This will print files and paths on the target to prove it does what you want
xargs tar -cf - < filename.list | ssh target tar -C / -tf -
# If that works right, this will actually create files on the target
xargs tar -cf - < filename.list | ssh target tar -C / -xf -

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change the file name and copy old file content to new file names.

Hi, I have a files in a directory as below :- ls -1 mqdepth-S1STC02 proc-mq-S1STC01 proc-mq-S1STC02 proc-mq-S1STC03 Whereever i have S1STC i need to copy them into new file with file name S2STC. expected output :- ls -1 mqdepth-S2STC02 proc-mq-S2STC01 proc-mq-S2STC02... (3 Replies)
Discussion started by: satishmallidi
3 Replies

2. Shell Programming and Scripting

how to copy the directory but not copy certain file

Hi experts cp bin root src /mnt but not copy bin/bigfile any help? ( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum) Thanks (6 Replies)
Discussion started by: yanglei_fage
6 Replies

3. Programming

how to copy downloaded file into my source file folder (putty/unix)

I need to "Ensure that when you download libchat.a from the VLE you have copied it to the same folder on ius as your source files. You then refer to the library (and the libraries it needs) with: gcc -o outputfile sourcefile.c -L. -lchat -lsocket -lnsl" But I have no idea what this means! (I... (2 Replies)
Discussion started by: fakuse
2 Replies

4. Red Hat

Copy certain file types recursively while maintaining file structure on destination?

Hi guys, I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash. I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also... (1 Reply)
Discussion started by: rockf1bull
1 Replies

5. UNIX for Dummies Questions & Answers

Copy a windows CVS file to the unix server as a svs file

I so desperately need a script to copy a windows csv file to my unix server and i know these should be at dummies but i have no bits. it is life & no job situation help please. thanks (1 Reply)
Discussion started by: zhegal
1 Replies

6. Shell Programming and Scripting

Match File and Copy File Script (Homework, Closed)

Can you please help on this? I am looking for the shell script which does following:- step 1: It should open the file /u/manish/input/FileIndex.dat and read line by line step 2: Once first line is read (for ex: File1), we have to find a file, that contains this matching... (4 Replies)
Discussion started by: teteguru1
4 Replies

7. UNIX for Dummies Questions & Answers

Copy a file from a dvd to the local AIX file system

Hi, I am a newbie to AIX, so please bear with me. I have mounted a dvd drive on AIX. I am trying to copy the file that is on the dvd drive on to the local machine. However, I get an error: cp: c1m_0001.gz: A system call received a parameter that is not valid. Can some one point me to the... (1 Reply)
Discussion started by: anurag1510
1 Replies

8. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies

9. Shell Programming and Scripting

how to copy a file to a directory ,where file and dir are sent as args to a function?

Hi all, I wanted to know how i can copy a file to a directory and then verify if that file is completely copied or not? Now the issues here is that the dir and the source file are to be sent as arguments to a function( this function should actually copy the files to a dir, then check if its... (0 Replies)
Discussion started by: wrapster
0 Replies
Login or Register to Ask a Question