I need to use scp update some directory at another server. It is similar to
for i in /usr/some/???/unknown/dir
do
cp /usr/some/file $i
done
so how can i do the search while the destination directories are on other server?
thank you
I need to use scp update some directory at another server. It is similar to
for i in /usr/some/???/unknown/dir
do
cp /usr/some/file $i
done
so how can i do the search while the destination directories are on other server?
thank you
If you have shell access on the remote server, create a list of the directories remotely (using find, or ls, or whatever you'd use in your shell script), and copy it back to the system you're copying from. Then you can use
for d in file_of_remote_dirs; do
scp /usr/some/file remote_machine:d;
done
for i in `ssh user@otherhost ls /usr/some/dir/`
do
scp user@otherhost:/usr/some/dir/$i .
done
for i in `ssh user@otherhost find /usr/some -type d -name dir`
do
scp user@otherhost:/usr/some/dir/$i .
done
the find is what you're looking for I guess...
Everybody forgets to handle spaces in file names :P
To reuse LB's example:
OLD_IFS=$IFS
IFS=$\'n'
for i in `ssh user@otherhost find /usr/some -type d -name dir`
do
scp user@otherhost:"/usr/some/dir/$i" .
done
IFS=$OLD_IFS
This will loop over each line of output instead of each word (and $i is quoted).