I normally work these things out reasonably quickly, but this one is a headache.
I have a shell script that loads some info about where to connect to and how from a text file, this is done using the read command. This works. It stores the arguments to be sent onto RSync in a variable call $rsyncargs.
I want to use the RSync arg -e which is used to pass details onto ssh, in my case a port number as so:
rsync -avz -e "ssh -p 222" dir/ [email protected]:dir/
the line in the text file looks like so:
-e "ssh -p 222"
the line of bash should be something like:
rsync -avz $rsyncargs $src $dst
this all works, except that the quotes mess up and I end up with
sending incremental file list
rsync: link_stat "/dir/to/shell/script/222"" failed: No such file or directory (2)
So it's trying to parse the contents of the quotes at the wrong stage. I've tried a list of different escaping mechanisms (like backslashes in the text file and using single quotes instead of double quotes in several places etc) but it all seems to end with similarly catastrophic (though not always identical) error messages.
any suggestions would be greatly appreciated (either to solve the original problem, or to get the ssh port changed in a less annoying way)