Search code examples
bashgnuplottcsh

translate from tcsh to bash issue


I'm trying to translate a tcsh script to a bash one. This script invokes gnuplot this way:

#!/bin/tcsh
<script commands>
gnuplot << EOF
set terminal png
<other commands>
plot <args>

I tried to just modify 'tcsh' to 'bash', but I get "here-document at line x delimited by end-of-file (wanted `EOF')". Why is this ?


Solution

  • Exactly as the error message says: you need to end the here document with the string given when it was begun, in this case, EOF. You can't just use the end of the file to terminate the here doc.

    As an example, here's a fragment from a script where I used a here doc:

    /usr/bin/gnuplot << GPLOT
    set terminal png
    set output "$3"
    set logscale xy
    set xlabel "$1"
    set ylabel "$2"
    plot "tmp2.$$" notitle
    GPLOT
    

    Since I began the here doc with GPLOT, bash looks for GPLOT to indicate the end of the here doc.