1

I have encountered a small issue with SCP (and also rsync). I need to copy certain files from server A (running SunOS 5.8) to server B (running SunOS 5.10).

First, I get the list of files (several hundred) via ssh and find

FILES=`ssh user@remote find ./ -name "*.sh" -o -name "*.cbs" -print`
scp -r user@remote:"$FILES" /u01/appl/somedir/ 

My problem is, I want to copy files with relative paths, e.g. product/11/ora/clean.sh creating also the directory structure (in result having /u01/appl/somedir/product/11/ora/clean.sh). Currently I am only able to download the file and no directories are created. As you can see I used -r flag in scp.

  • Unsure of the goal due to the wording but my sense of what you're trying to do is copy a directory tree on the local system to a remote system over ssh but the parent directory paths may be different? Is this something rsync over ssh could help with? – Bratchley Apr 2 '13 at 16:44
1

The shell will expand your construct user@remote:"$FILES" into something you don't want. The first will have the user@remote: prefix but the rest won't.

You can pipe tar over SSH, so it might be easier to build up an include file with your "find" command as above, then you can do approx this:

find ...stuff... > myfiles
scp myfiles user@remote
ssh user@remote "tar -Imyfiles -cvf - " | tar -C /u01/appl/somedir -xf-

You could probably get crafty and combine the find and the tar with the right quoting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.