tags:

views:

24

answers:

2

Hi,

I've been asked to modify a bash script at my internship and since yesterday was the first time I started reading up on Bash syntax, I'm having a hard time figuring out a "syntax error: unexpected end of file" error. I was wondering if anyone would be able to help me out.

The last part of the script is:

    echo "  " >>${MAILLOG}

    echo "Building CSAPI SDK" >>${MAILLOG}
        cd ${BuildsDIR}
        make sdk
    # Wait 3 minutes for the HDXs to reboot and SDK build to complete
    echo "Waiting for the HDXs to reboot and SDK build to complete..." >>${MAILLOG}
        sleep 180
    echo "Running PyUnit tests" >>${MAILLOG}
        cd Common/csapi/pyunit
        make test >>${TESTLOG} 2>&1

    TestReportLink=`mklink ${BUILDURL}/${1}/build/Common/csapi/pyunit/report.xml`
    TestLogLink=`mklink ${BUILDURL}/${1}/build/${1}.test.log`

    echo "Test report: ${TestReportLink}" >>${MAILLOG} 
    echo "Test log: ${TestLogLink}"  >>${MAILLOG} 
    # Wait 3 minutes for the tests to complete
        sleep 180
A: 

Like noted in http://superuser.com/q/184861/48480, the mklink() replaces "/" with "\". e.g. ${BUILDURL}/${1}/build/${1}.test.log gets replaced by something like ausdatos01\\development\\mrahman\\projects\\builds\\autobuilder\\<source directory>\\build\\<source directory>.test.log. Since you tagged the question being *NIX-related, this path might not exist. On first sight, it looks, like the script is written to work on a Windows host (e.g. in cygwin...).

What happens, if you change the mklink to

mklink () {
#    node="\\\\$1"
#    echo $node`echo $2|sed 's/\//\\\\/g'`
}
MaoPU
+4  A: 

On about line 129 of that script this appears:

    EOFBUILDFAILUREMSG

remove the leading white space from that line and your error message will go away.

That's the ending delimiter of a here document. You could leave in the leading white space if line 123 was changed to have the redirection operator as <<- and the white space consisted of only tabs (no spaces):

    cat <<-EOFBUILDFAILUREMSG >>${MAILLOG}
Dennis Williamson
That worked, thanks :)
iman453