LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /.cshrc: Syntax error: unexpected end of file (https://www.linuxquestions.org/questions/linux-newbie-8/cshrc-syntax-error-unexpected-end-of-file-4175692089/)

Mirror of Erised 03-16-2021 01:28 AM

/.cshrc: Syntax error: unexpected end of file
 
Hello to all the wonderful people out there,

I am a newbie in the world of Linux (obviously!!!!). I would love to get some help regarding the following matter. I am trying to install a software called SPARTA+. While installing I sourced the .cshrc file and I faced the following error when .

/.cshrc: line 5: syntax error: unexpected end of file

This is how the .cshrc file looks like

if (-e $SPARTAP_Dir/sparta+Init.com) then
source $SPARTAP_Dir/sparta+Init.com
endif

It will be great if someone can tell me what's wrong with this .cshrc file or what does the error mean.
Thank you

pan64 03-16-2021 04:15 AM

I guess the file $SPARTAP_Dir/sparta+Init.com was not ok, but without details hard to say more.

MadeInGermany 03-16-2021 06:40 AM

Yes indeed.
Put
Code:

set echo
before the source command to see what it does.

X-LFS-2010 03-16-2021 09:55 PM

looks like an ad for asian software funded by USA to me. also - it says it's gains are "modest"

also, "set echo" is NOT AN ANSWER, and csh is default shell in freeBSD not linux

X-LFS-2010 03-16-2021 09:59 PM

/.cshrc: line 5: syntax error: unexpected end of file IS THE PROBLEM

the sytax in this case doesn't work in bash or csh if i remember a little csh correctly

if [ -e $SPARTAP_Dir/sparta+Init.com ] ; then
source $SPARTAP_Dir/sparta+Init.com
endif

if (-e $SPARTAP_Dir/sparta+Init.com) ; then
source $SPARTAP_Dir/sparta+Init.com
endif

if $(test -e $SPARTAP_Dir/sparta+Init.com) ; then
source $SPARTAP_Dir/sparta+Init.com
endif

cynwulf 03-19-2021 10:25 AM

https://spin.niddk.nih.gov/bax/software/SPARTA+/

The instructions are for macOS (and apparently "linux9"... RHEL9?) and assume that either csh or tcsh are installed.

You should post the whole contents of ~/.cshrc, along with the distribution you are using and what you enter to produce the error, if you expect to receive any meaningful assistance.

Emerson 03-19-2021 11:55 AM

Missing line terminator probably, incompatible editor.

shruggy 03-19-2021 12:59 PM

^Nope. Tried it with tcsh 6.20.00, 6.21.00, and csh 20110502. All of them recognize scripts without the trailing newline just fine.

Emerson 03-19-2021 01:04 PM

OP said they sourced it, never mentioned what shell was used. It may been even bash.

shruggy 03-19-2021 02:38 PM

Quote:

Originally Posted by Emerson (Post 6232120)
It may been even bash.

Yep, you're right. Sourcing a C-Shell script in Bash gives this error:
Code:

$ cat script.csh
#!/bin/csh
if(-e $Undefined_Variable/a_file)then
        source $Undefined_Variable/a_file
endif
$
csh script.csh
Undefined_Variable: Undefined variable.
$
bash -c 'source script.csh'
script.csh: line 5: syntax error: unexpected end of file

I also suspect that OP haven't defined $SPARTAP_Dir anywhere, so even sourcing it in csh would fail.

computersavvy 03-19-2021 04:13 PM

I saw 2 things in line 5
Code:

if (-e $SPARTAP_Dir/sparta+Init.com) then
    ^                              ^ ^
    |                              | |
1. test requires space between the argument and the enclosing brackets.
2. if - then requires that then be on the next line or that there be a ; between the test and then.
Thus it should be

if ( -e $SPARTAP_Dir/sparta+Init.com ); then

Regardless of what else is wrong the form of that line must be fixed.

shruggy 03-19-2021 04:37 PM

@computersavvy. No. This is csh. Even the white space around parentheses is optional. The following is perfectly correct in csh:
Code:

if(-e $SPARTAP_Dir/sparta+Init.com)then


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