On Fri 04 Apr 2008, Sterling Windmill wrote:

> I am modifying a bash script of mine to issue an rsync to a remote host with a non-standard ssh port.
> Unfortunately, no combination of "bashisms" seems to make it work properly.
> Code snippet:
> ...
> RSYNC_OPTIONS="-aH --delete --numeric-ids -e \'ssh -p 2292\'"
> RSYNC="ionice -c3 rsync $RSYNC_OPTIONS"

Nested quotations usually do something else than you'd expect...

> $SOURCE=/some/dir
> $DEST=root@

Are you sure about the above lines? I'd lose the $ in the 1st column.
(Or was that your shell prompt...)

> $RSYNC --progress "$SOURCE" "$DST"

That will probably present the arguments to rsync differently then
expected. A simple test:

$ cat showargs.sh

for i; do
echo "ARG: $i"

$ RSYNC_OPTIONS="-aH --delete --numeric-ids -e \'ssh -p 2292\'"
$ RSYNC="ionice -c3 rsync $RSYNC_OPTIONS"
$ SOURCE=/some/dir
$ DEST=root@
$ ./showargs.sh $RSYNC --progress "$SOURCE" "$DST"
ARG: ionice
ARG: -c3
ARG: rsync
ARG: -aH
ARG: --delete
ARG: --numeric-ids
ARG: -e
ARG: \'ssh
ARG: -p
ARG: 2292\'
ARG: --progress
ARG: /some/dir

(With $DEST instead of $DST it shows root@ as the
last ARG, instead of the empty one now.)

I wish you much pleasure in trying to solve this in this way :-)
I'd create a ssh-2292 commmand that looks like:

exec /usr/bin/ssh -p 2292 "$@"

and pass that to the -e option.

Alternatively you could create an entry for that host in ~/.ssh/config
and put the port in there.

Paul Slootman
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html