LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   line 23 :syntax error unexpected end of file detected (https://www.linuxquestions.org/questions/linux-software-2/line-23-syntax-error-unexpected-end-of-file-detected-912913/)

nipuniitg 11-10-2011 07:31 PM

line 23 :syntax error unexpected end of file detected
 
Below is a script in a software.
I used the command "source setup_env.csh" and it says
"line 23:syntax error unexpected end of file detected"


#setup_env.csh
echo "#####################################################################"
echo ""
echo "Setting up the environment ..."

if ( ! ( -d bin ) || ! ( -d lib ) ) then
echo "ERROR: Your installation is not proper or you are you are sourcing itt from a wrong directory ..."
echo "Contact support@questatechnologgies.com for any help "
echo "#####################################################################"
exit 1
endif

setenv QUESTATECH_HOME $PWD

setenv PATH "$QUESTATECH_HOME/bin:$PATH"

echo ""
echo "Completed the environment setup, you're all set to run the tool(s) ..."
echo ""
echo "#####################################################################"
echo ""
exit 0



thanks a lot if u help...and waiting eagerly for your reply

jlinkels 11-10-2011 08:36 PM

The close tag for if is fi, not endif
At least I hope csh sytax is the same as bash.

jlinkels

David the H. 11-10-2011 09:18 PM

Please use [code][/code] tags around your code, to preserve formatting and to improve readability. ...And to prevent the page from side-scrolling.

An "end of file" error nearly always means that you've missed a closing mark of some kind. The parser reached the end of the file without finding the quote-mark, character, or word that's supposed to end an expression (or it found an unmatched opening mark that's not supposed to be there).

Don't pay too much attention to the line number given with the errors either; the message indicates the point where it couldn't continue to process the script, which is often not the place where the actual mistake lies. Work backwards from that point until you find the mistake.

@jinkels No, it appears that endif is correct.

http://www.csem.duke.edu/Cluster/csh_basics.htm#if

That means, however, that there are no mistakes that I can see offhand. :scratch: Not that I'm very familiar with csh myself. But most of the lines are just simple echo strings, all properly quoted AFAICT.

John VV 11-10-2011 11:35 PM

line 22 is "exit 0 " so 23 is the missing new line ? maybe ?


code tags would help

nipuniitg 11-11-2011 11:38 AM

thanks a lot for your replies but i couldn't make out the mistake....
my observation says that the error is in the "if" conditional statement(i used a test echo before "if" and it worked fine)
so anyone who pin points the flaw reply me soon....


thanks for your patience and waiting for your cursor to be on the 'reply post' button

TB0ne 11-11-2011 12:07 PM

Quote:

Originally Posted by nipuniitg (Post 4521672)
thanks a lot for your replies but i couldn't make out the mistake....
my observation says that the error is in the "if" conditional statement(i used a test echo before "if" and it worked fine) so anyone who pin points the flaw reply me soon....
thanks for your patience and waiting for your cursor to be on the 'reply post' button

Instead of waiting or telling us to hurry and "reply me soon", why don't you try to figure it out yourself?

Running the script under bash causes that error...and judging by the extension, it's a c-shell script. If I go into a cshell, it works fine...if not, it produces the error. Put a "#!/bin/csh" at the top.

nipuniitg 11-11-2011 08:35 PM

@TBone even "#!/bin/csh" did not work....

TB0ne 11-12-2011 03:44 PM

Quote:

Originally Posted by nipuniitg (Post 4521923)
@TBone even "#!/bin/csh" did not work....

Ok...is that the path for csh on your system?? What version? Because under csh 6.17.02, it works fine, and under bash it works fine as well, if I specify the /bin/csh line at the very top of the script.

What version/distro of Linux are you using, and do you want this to be a csh or bash script? It works fine as is under a csh environment, or by calling it explicitly in bash, as stated.

Tinkster 11-13-2011 02:12 PM

Moved: This thread is more suitable in <Software> as it has nothing to do w/ the kernel, and has been moved accordingly to help your thread/question get the exposure it deserves.


All times are GMT -5. The time now is 02:06 AM.