<div>It seems to me that the | is interpreted literally. You need to escape it like this in your command variable: \|</div><div><br></div><div>To make the logfile and source/destination paths "space proof" when you store the command in a variable you add escaped " around the paths like this: \"/path/to/logfile\".</div>
<div>You should also check out running your command with eval, even if it is not needed in your exact scenario.</div><div><br></div><div><font><span style="font-family:arial,helvetica,sans-serif">Mvh</span></font><br><br>
<b>Hans-Kristian Bakke</b><br><font size="1"><span style="color:rgb(51,51,51)">Mob: 91 76 17 38</span></font><br></div>
<br><br><div class="gmail_quote">On 24 January 2013 12:08, Joe <span dir="ltr"><<a href="mailto:josephj@main.nc.us" target="_blank">josephj@main.nc.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In my new bash script, I'm doing what I think is a very simple rsync<br>
command the way I'm used to doing it.  I just do a lot of setup and<br>
checking before I get to it.<br>
<br>
When I run it, it gets very unhappy with me.  It's probably something<br>
very simple.<br>
<br>
I need to build the rsync command in a string so that some things can go<br>
away - like if my variables DRY_RUN and DELETE are undefined, they<br>
should be gone when the string is evaluated.  Without this, DRY_RUN<br>
turns into "" and rsync still sees it as the first (null) parameter and<br>
gets totally lost.  I brought this up in a previous thread here awhile ago.<br>
<br>
The ls commands are only in the script to document the state of things<br>
right before rsync runs.<br>
The first version of COMMAND (commented out here) was intended to<br>
protect the arguments if there were embedded blanks.  It also fails when<br>
I use it, but with slightly different error messages.<br>
<br>
/home/bigbird/pgm/backup_periodic/ is where the script is stored and is<br>
the current directory when it runs.  This script is nested within a<br>
couple of others, the first of which calls the the second using sudo, so<br>
everything runs as root.<br>
<br>
I'm running my script with<br>
shopt -s -o xtrace  # debug<br>
shopt -s -o verbose  # debug<br>
That's what makes this output a little dense, but complete.<br>
<br>
What the heck am I doing to get rsync so confused?<br>
<br>
(The destination was built using my previous notebook (RIP).  That's why<br>
there's so much more in it.  I'll move things around before I run<br>
anything with --delete.)<br>
<br>
BTW, when I first ran this, my log file did not exist and rsync said it<br>
would ignore it because it didn't exist.  In the past, this worked<br>
fine.  If it wasn't there, rsync just created it (which is the expected<br>
behavior - at least to me).<br>
<br>
TIA<br>
    Joe<br>
<br>
kubuntu precise (12.04),  64-bit i5 notebook  running in konsole under KDE.<br>
bigbird@ramdass:~/bin$ rsync --version<br>
rsync  version 3.0.9  protocol version 30<br>
<br>
ls -l ${LOGFILE1}<br>
+ ls -l /home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
-rw-rw-rw- 1 bigbird bigbird 0 Jan 24 05:11<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
ls -l ${LOGFILE2}<br>
+ ls -l /home/bigbird/rlog/ramdass-01-internal_webcasts_output<br>
-rw-rw-rw- 1 root root 0 Jan 24 05:11<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_output<br>
ls -l ${MOUNT_POINT[0]}/${DIRECTORY[0]}/<br>
+ ls -l /media/dataspace/data/webcasts/<br>
total 12<br>
drwxrwxr-x  5 bigbird bigbird 4096 Dec 14 13:24 Business<br>
drwxrwxr-x 13 bigbird bigbird 4096 Jan 19 06:07 Health<br>
drwxrwxr-x 10 bigbird bigbird 4096 Jan 10 12:38 Spiritual<br>
ls -l ${MOUNT_POINT[1]}/${DIRECTORY[1]}<br>
+ ls -l /media/dest/data/webcasts<br>
total 44<br>
drwxr-xr-x  6 bigbird bigbird 4096 Jun  4  2011 Business<br>
drwxr-xr-x  2 bigbird bigbird 4096 May  5  2012 Comedy<br>
drwxr-xr-x  2 bigbird bigbird 4096 Oct 20  2011 Computer<br>
drwxr-xr-x  4 bigbird bigbird 4096 Jun  4  2011 Eco<br>
drwxr-xr-x  3 bigbird bigbird 4096 Oct 26  2011 Education<br>
drwxr-xr-x 13 bigbird bigbird 4096 Oct 31  2011 Health<br>
drwxr-xr-x  2 bigbird bigbird 4096 Nov  4  2011 Links<br>
drwxr-xr-x  2 bigbird bigbird 4096 Nov  6  2011 Music<br>
drwxr-xr-x  2 bigbird bigbird 4096 Sep 26  2011 Nature<br>
drwxr-xr-x 10 bigbird bigbird 4096 Nov  2  2011 Spiritual<br>
-r--r--r--  1 bigbird bigbird 1043 Dec 19  2010 webcasts-info.txt<br>
##COMMAND="rsync ${DRY_RUN} -avushi ${DELETE} --stats --progress<br>
--log-file=\"${LOGFILE1}\" \"${MOUNT_POINT[0]}/${DIRECTORY[0]}/\"<br>
\"${MOUNT_POINT[1]}/${DIRECTORY[1]}\" | tee \"${LOGFILE2}\""<br>
COMMAND="rsync ${DRY_RUN} -avushi ${DELETE} --stats --progress<br>
--log-file=${LOGFILE1} ${MOUNT_POINT[0]}/${DIRECTORY[0]}/<br>
${MOUNT_POINT[1]}/${DIRECTORY[1]} | tee ${LOGFILE2}"<br>
+ COMMAND='rsync -n -avushi  --stats --progress<br>
--log-file=/home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
/media/dataspace/data/webcasts/ /media/dest/data/webcasts | tee<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_output'<br>
echo "RUNNING [[${COMMAND}]]" ## let user see what's being done<br>
+ echo 'RUNNING [[rsync -n -avushi  --stats --progress<br>
--log-file=/home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
/media/dataspace/data/webcasts/ /media/dest/data/webcasts | tee<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_output]]'<br>
RUNNING [[rsync -n -avushi  --stats --progress<br>
--log-file=/home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
/media/dataspace/data/webcasts/ /media/dest/data/webcasts | tee<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_output]]<br>
${COMMAND}                    ## Do it!<br>
+ rsync -n -avushi --stats --progress<br>
--log-file=/home/bigbird/rlog/ramdass-01-internal_webcasts_log<br>
/media/dataspace/data/webcasts/ /media/dest/data/webcasts '|' tee<br>
/home/bigbird/rlog/ramdass-01-internal_webcasts_output<br>
sending incremental file list<br>
rsync: link_stat "/home/bigbird/pgm/backup_periodic/|" failed: No such<br>
file or directory (2)<br>
rsync: link_stat "/home/bigbird/pgm/backup_periodic/tee" failed: No such<br>
file or directory (2)<br>
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]:<br>
Broken pipe (32)<br>
ERROR: destination must be a directory when copying more than 1 file<br>
rsync error: errors selecting input/output files, dirs (code 3) at<br>
main.c(571) [Receiver=3.0.9]<br>
rsync: connection unexpectedly closed (9 bytes received so far) [sender]<br>
rsync error: error in rsync protocol data stream (code 12) at io.c(605)<br>
[sender=3.0.9]<br>
RC=$?<br>
+ RC=12<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Please use reply-all for most replies to avoid omitting the mailing list.<br>
To unsubscribe or change options: <a href="https://lists.samba.org/mailman/listinfo/rsync" target="_blank">https://lists.samba.org/mailman/listinfo/rsync</a><br>
Before posting, read: <a href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank">http://www.catb.org/~esr/faqs/smart-questions.html</a><br>
</font></span></blockquote></div><br>