• Shell script issue; rsync error wtf

    From Khelair@VERT/TINFOIL to All on Sat Jun 13 07:06:06 2015
    I'm working with the following shell script for automating a task that I need to accomplish for one of my clients... Unfortunately the version that I've written is having some really weird bugs creeping up when it's executed as a shell script. It's proving pretty problematic to debug, as when I throw the script into debugging mode and cut 'n paste the actual command that it's trying to execute into the shell, it works just fine. When it's trying to execute via the script I get the following error:

    -=-=-=-=-
    ./sync_static_to_dev.sh
    Rsyncing /server/assets with options: -vHrltD -e \'ssh -p 22\' dgetsman@10.183.1.251:/server/assets /server/assets
    Unexpected remote arg: dgetsman@10.183.1.251:/server/assets
    rsync error: syntax or usage error (code 1) at main.c(1201) [sender=3.0.6]
    Done
    -=-=-=-=-

    I thought at first that perhaps there was an issue with the way that I had used the quoting within the shell. I've had other weird, esoteric kinds of errors due to quoting incorrectly via shell script previously. So I went back through the script that follows and ended up escaping all occurrances of the single-tick (') quoting, but still ended up getting the same error.
    So anyway, if there are any shell script wizards in the house, any you've got any ideas on why this is failing as a script, but working when I cut 'n paste the debugging output of the command straight into the shell, I'd greatly appreciate any feedback you might be able to offer.
    Script follows:

    -=-=-=-=-
    #!/bin/sh

    # script's functionality is to rsync static assets from whatever directory
    # (specified in constants) from production to whatever directory specified on
    # command line with an optional default (later, meh, nunathismattahs)

    WHICH='/usr/bin/which'

    STATIC_ASSETS='/server/assets'
    SOURCE='10.183.1.251' #use the quick link; this'll break quick

    DEBUGGING=0
    VERBOSE=1

    WHOAMI=`$WHICH whoami`
    RSYNC=`$WHICH rsync`

    if [ -n "$1" ] ; then
    USER=$1
    else
    USER=`$WHOAMI`
    fi

    if [ $VERBOSE -gt 0 ] ; then
    RSYNC_OPTS="-vHrltD -e 'ssh -p 22' $USER@$SOURCE:$STATIC_ASSETS \
    $STATIC_ASSETS"
    else
    RSYNC_OPTS="-HrltD -e 'ssh -p 22' $USER@$SOURCE:$STATIC_ASSETS \
    $STATIC_ASSETS"
    fi

    if [ $DEBUGGING -eq 0 ] ; then
    if [ $VERBOSE -gt 0 ] ; then
    #RSYNC_OPTS="-vHrltD -e 'ssh -p 22' $USER@$SOURCE:$STATIC_ASSETS \
    # $STATIC_ASSETS"

    echo Rsyncing $STATIC_ASSETS with options: $RSYNC_OPTS
    $RSYNC $RSYNC_OPTS
    echo Done
    else
    #RSYNC_OPTS="-HrltD -e 'ssh -p 22' $USER@$SOURCE:$STATIC_ASSETS \
    # $STATIC_ASSETS"

    $RSYNC $RSYNC_OPTS
    fi
    else
    echo $RSYNC $RSYNC_OPTS
    fi

    -=-=-=-=-

    Anything you might be able to offer is greatly appreciated! TIA

    -D/K

    ---
    Borg Burgers: We do it our way; your way is irrelevant.
    þ Synchronet þ Tinfoil Tetrahedron BBS telnet://tinfoil.synchro.net
  • From Brian Wallace@VERT/TIME/BATTLEST to Khelair on Sun Feb 14 16:44:02 2016
    Re: Shell script issue; rsync error wtf
    By: Khelair to All on Sat Jun 13 2015 12:06 am

    I've been getting a lot of rsync errors the last month or so, I think it's rsync on 64 bit vs older 32 bit (and less) systems. Check the versions. You seem to say it works OK if you just copy and paste the command you want? I think that's because of buffering-pipes have limited buffer sizes and rsync uses pipes. rsync is more like a shell on top of scp, so when rsync fails I fall back to scp to get it done. I have a WDMyCloud which is Ubuntu under the hood, and rsync on that almost never fails, but my AMD 64 bit machine fails like crazy as the WDMyCloud and all my other systems are 32 bit. They started handling things differently with 64 bit systems and it's not all ironed out and compatable yet. Not sure if there's an option for that, but there might be, I haven't figured out my problems with it really, just know 64 bit vs 32 bit is part of it. I know that because all the 32 bit systems work together fine, it's just the 64 bit system that has problems to everything else. I'll try to let you know if I find a fix for my use as it should help yours too.

    ---
    þ Synchronet þ Battlestar BBS - battlestarbbs.dyndns.org