[PLUG] What in this file could make both rsync and git fail

Ankur Sinha sanjay.ankur at gmail.com
Thu Dec 30 04:43:49 PST 2010


Hello,

I have a simple shell script which I want to upload using rsync, or to a
git repository. For some reason, rsync fails, and so does git. rsync
fails at "generating_files phase=1" (and times out), and git just hangs
before timing out. I can't seem to paste the file to fpaste.org either.
I get a 503 for some reason. I've checked my network, and therefore
something in the file is erroneous. Can someone please confirm/clarify
this? It's because of some unprintable characters someplace (I think).
I've copied it to a new file, moved it, changed permissions, but the
error persists. 

#!/bin/bash
#
# File : wiley2bibtex : convert the wiley citations to bibtex
#

usage ()
{
    echo -ne "wiley2bibtex : Convert citations from Wiley on line
library to BibTeX\n"
    echo -ne "Usage: wiley2bibtex inputfile outputfile\n"
}

parse()
{
    if [ -f /usr/bin/dos2unix ] ; then  
        dos2unix "$1" > /dev/null 2>&1 
    else
        echo "Could not find dos2unix. Continuing without converting"
    fi

    # Check if it's downloaded from Wiley
    grep "Provider: John Wiley & Sons, Ltd" "$1" > /dev/null

    if [ 0 -ne $? ]; then
        echo -ne "Does not appear to be from the Wiley online library\n"
        echo -ne "Misses the required Provider: header\n"
        echo -ne "Exiting"
        exit 1
    fi

    echo -ne "@Article{" > $2

    # Get the values
    TY=$(grep "TY  -" "$1" | awk 'BEGIN { FS = " - " }; { print $2 }')
    TITLE=$(grep "TI  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    JOURNAL=$(grep "JO  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    VOLUME=$(grep "VL  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    ISSUE=$(grep "IS  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    PUBLISHER=$(grep "PB  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    SERIAL=$(grep "SN  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    URL=$(grep "UR  -" "$1" | awk 'BEGIN { FS = " - " }; { print $2 }')
    DOI=$(grep "DO  -" "$1" | awk 'BEGIN { FS = " - " }; { print $2 }')
    START_PAGE=$(grep "SP  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    END_PAGE=$(grep "EP  -" "$1" | awk 'BEGIN { FS = " - " }; { print
$2 }')
    YEAR=$(grep "PY  -" "$1" | awk 'BEGIN { FS = " - " }; { print $2 }')
    AUTHOR_NUM=$(grep "AU  -" "$1" | wc -l)
    # understand this!
    for i in "$(grep "AU  -" $1 )"; do
        AUTHOR=$(echo "$i" | awk 'BEGIN{FS = " - "}; { print $2}' | awk
'BEGIN {FS = ","};{print $2 " " $1 ","}')
    done
    AUTHOR=$(echo $AUTHOR | sed "s/\,$/./")

    # create ourselves a keyword
    PRIME_AUTHOR=$(grep "AU  -" -m 1 $1 | awk 'BEGIN{FS = " - "}; {print
$2}' | awk 'BEGIN {FS = ","};{print $2}')
    KEYWORD="$PRIME_AUTHOR$YEAR"

    # Start making our file!
    echo -ne $KEYWORD >> $2 ; echo "," >> $2
    if [ "$DOI" ] ; then
        echo -ne "\tDoi = {" >> $2 ; echo -ne $DOI >> $2 ; echo "}," >>
$2
    fi
    if [ "$AUTHOR" ] ; then
        echo -ne "\tauthor = {" >> $2 ; echo -ne $AUTHOR >> $2 ; echo
"}," >> $2
    fi
    if [ "$TITLE" ] ; then
        echo -ne "\ttitle = {" >> $2 ; echo -ne $TITLE >> $2 ; echo "},"
>> $2
    fi
    if [ "$JOURNAL" ] ; then
        echo -ne "\tjournal = {" >> $2 ; echo -ne $JOURNAL >> $2 ; echo
"}," >> $2
    fi
    if [ "$VOLUME" ] ; then
        echo -ne "\tvolume = {" >> $2 ; echo -ne $VOLUME >> $2 ; echo
"}," >> $2
    fi
    if [ "$ISSUE" ] ; then
        echo -ne "\tissue = {" >> $2 ; echo -ne $ISSUE >> $2 ; echo "},"
>> $2
    fi
    if [ "$YEAR" ] ; then
        echo -ne "\tyear = {" >> $2 ; echo -ne $YEAR >> $2 ; echo "},"
>> $2
    fi
    if [ "$URL" ] ; then
        echo -ne "\turl = {" >> $2 ; echo -ne $URL >> $2 ; echo "}," >>
$2
    fi
    if [ "$PUBLISHER" ] ; then
        echo -ne "\tpublisher = {" >> $2 ; echo -ne $PUBLISHER >> $2 ;
echo "}," >> $2
    fi
    if [ "$PAGES" ] ; then
        echo -ne "\tpages = {" >> $2 ; echo -ne $START_PAGE >> $2 ; echo
-ne "-" >> $2 ; echo -ne $END_PAGE >> $2 ; echo "}," >> $2
    fi
    echo -e "}" >> $2

    cat $2



}
if [ $# -ne 2 ] ; then
    echo "Incorrect usage"
    usage
    exit 1;
fi

if [ ! -f "$1" ] ; then
    echo "$1: No such file." 2>&1
    usage                 # Print usage message and exit.
    exit 2
fi

parse $*


Thanks,
regards,
Ankur




More information about the plug-mail mailing list