Richard Lewis wrote:
I suppose what I need is a sort of 'rmkdir' with the -p switch:
rmkdir -p $HOST:$ROOT/`dirname $f`
If you can scp to that machine, I presume you can ssh to it too, right? Then you can use ssh to do the mkdir:
# prepare test mak@yoda$ mkdir -p foo/bar; touch foo/bar/baz mak@yoda$ ssh taurus mkdir a_dir
# copy mak@yoda$ ssh taurus mkdir -p a_dir/`dirname /home/mak/foo/bar/baz` mak@yoda$ scp /home/mak/foo/bar/baz \ taurus:a_dir/`dirname /home/mak/foo/bar/baz` baz 100% 0 0.0KB/s 00:00 mak@yoda$ ssh taurus ls a_dir/home/mak/foo/bar/baz a_dir/home/mak/foo/bar/baz
PS. Theres no need to use scp if a solution exists using something else....
rsync will also do what you want, without the mkdir:
mak@yoda$ ssh taurus mkdir some_dir
mak@yoda$ rsync -e `which ssh` --relative \ /home/mak/foo/bar/baz taurus:some_dir mak@yoda$ ssh taurus ls some_dir/home/mak/foo/bar/baz some_dir/home/mak/foo/bar/baz
-- Martijn