Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 52488  / 3 Years ago, fri, june 25, 2021, 4:05:23

Can someone explain why the end of the file is unexpected on line 49? (Line 49 is one line after the last line)



#!/bin/bash 

timeend=$(date -u +%H%M)
timestart=$(date --date "$timeend 30 minutes ago" -u +%H%M)
firsttime=0

while true
do
if [[ $firsttime -eq 0 ]]; then
time=$timestart
increment=0
fi
if [[ $firsttime -ne true ]]; then
increment=$(( $increment + 2 ))
time=$(( $timestart + $increment ))
fi
if [[ $time -ge $timeend ]]; then
break
fi

gpnids << EOF
RADFIL = NEXRIII|CLT|TR0
RADTIM = "$time"
TITLE = 1/-2
PANEL = 0
DEVICE = gif|radar"$increment".gif|1280;1024|C
CLEAR = Y
TEXT = 1/2/2/hw
COLORS = 7
WIND =
LINE =
CLRBAR =
IMCBAR = 5/v/LL/.005;.6/.4;.01
GAREA = dset
MAP = 24 + 23 + 1/1/2 + 14 + 15/1/2
LATLON = 0
OUTPUT = t

$mapfil = lorvus.usg + hicnus.nws + hipona.nws + louhus.nws + loisus.nws
run

exit
EOF
firsttime=1

gpend

done

More From » bash

 Answers
0

You should also have gotten another error which is perhaps more informative:



/home/terdon/scripts/b.sh: line 49: warning: here-document at line 21 delimited by end-of-file (wanted `EOF')


/home/terdon/scripts/b.sh: line 50: syntax error: unexpected end of file



Your error is that you have spaces before the string that ends the heredoc. To take a simple example, this complains:


#!/bin/bash 

cat << EOF
hello
EOF

But this doesn't:


#!/bin/bash 

cat << EOF
hello
EOF

[#24544] Saturday, June 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atetamme

Total Points: 11
Total Questions: 121
Total Answers: 109

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;