Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm posting with the solution. The OS I'm working with is Red Hat Enterprise Linux (RHEL) 7.2.
I'm working with a script to execute an oracle procedure. The first and last lines are:
sqlplus -S /NOLOG << EOF >> $LOGFILE 2>>$LOGFILE
exit
EOF
I copied the lines verbatim from a working korn shell script, but when I went to execute it I got
-ksh: .: syntax error: `<<' unmatched
Searching the documentation says there is some kind of missing character, or line feed, or a space in the first position of a line between the two EOFs. I compared the working and non-working scripts in TextPad and using vi. (We use a mishmash of PC tools and command line edits when we work with scripts.) Nothing seemed mismatched.
Solution:
I ran the file command in the Linux server environment:
file run_WH_Monthly_PYR20.ksh
here's the result:
run_WH_Monthly_PYR20.ksh: Korn shell script, ASCII text executable, with CRLF line terminators
I edited the script in TextPad and did a Save As - the file format was PC. I saved it as file format UNIX and tried the file command again:
file run_WH_Monthly_PYR20.ksh
run_WH_Monthly_PYR20.ksh: Korn shell script, ASCII text executable
I tried to execute again. This time no syntax errors - the script ran perfectly.
I'm sure there's a Linux command solution that would reformat the script, but this worked for me.
I'm posting with the solution. The OS I'm working with is Red Hat Enterprise Linux (RHEL) 7.2.
I'm working with a script to execute an oracle procedure. The first and last lines are:
sqlplus -S /NOLOG << EOF >> $LOGFILE 2>>$LOGFILE
exit
EOF
I copied the lines verbatim from a working korn shell script, but when I went to execute it I got
-ksh: .: syntax error: `<<' unmatched
Searching the documentation says there is some kind of missing character, or line feed, or a space in the first position of a line between the two EOFs. I compared the working and non-working scripts in TextPad and using vi. (We use a mishmash of PC tools and command line edits when we work with scripts.) Nothing seemed mismatched.
Solution:
I ran the file command in the Linux server environment:
file run_WH_Monthly_PYR20.ksh
here's the result:
run_WH_Monthly_PYR20.ksh: Korn shell script, ASCII text executable, with CRLF line terminators
I edited the script in TextPad and did a Save As - the file format was PC. I saved it as file format UNIX and tried the file command again:
file run_WH_Monthly_PYR20.ksh
run_WH_Monthly_PYR20.ksh: Korn shell script, ASCII text executable
I tried to execute again. This time no syntax errors - the script ran perfectly.
I'm sure there's a Linux command solution that would reformat the script, but this worked for me.
The linux command is dos2unix. It converts the End Of Line (EOL) characters from DOS/Windows' CRLF to linux's LF.
Alternatively, if using FTP/SFTP to transfer a file, using ascii mode will convert the EOL characters from CRLF to LF
And yes, one gets unclear error messages in unix sometimes when a script has CRLF line ends.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.