Find the answer to your Linux question:
Results 1 to 7 of 7
Hi! I was trying to set path in csh.cshrc to one of the programs I am working on, but although I managed to do so, I've come upon a problem. ...
  1. #1
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14

    unexpected token `('

    Hi!

    I was trying to set path in csh.cshrc to one of the programs I am working on, but although I managed to do so, I've come upon a problem. When I typed "source csh.cshrc", I got following message:

    Code:
    [root@localhost work]# source /etc/csh.cshrc
    -bash: /etc/csh.cshrc: line 28: syntax error near unexpected token `('
    -bash: /etc/csh.cshrc: line 28: `        foreach i ( /etc/profile.d/*.csh )'
    This is a part of csh.cshrc containing that line:

    Code:
    if ( -d /etc/profile.d ) then
    	set nonomatch
            foreach i ( /etc/profile.d/*.csh )
    		if ( -r $i ) then
                   		source $i
    		endif
            end
    	unset i nonomatch
    endif
    Thank you for your time and effort.

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    Apparently run in bash:
    Code:
    -bash: /etc/csh.cshrc ...
    cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    Hmm.. Thanks, but I'm still in the mist of what I need to do.. Man pages weren't as helpful as I hoped them to be. ::embarrassed::

    Code:
    [archie.leach@localhost etc]$ bash csh.cshrc
    csh.cshrc: line 28: syntax error near unexpected token `('
    csh.cshrc: line 28: `        foreach i ( /etc/profile.d/*.csh )'

  4. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    The bash and csh shells are incompatible with one another.

    To get farther, do this:
    Code:
    csh
    then, if necessary:
    Code:
    source csh.cshrc
    As gently as I can: I am not altogether comfortable providing advice to you given that you do not seem to know the difference between bash and csh, and that you are running as root. That is a dangerous combination.

    If this is a learning situation for you, then, indeed, you will learn a lot by your mistakes. However, if there are other people on this system, then essentially all of their work is at risk because of your lack of knowledge.

    A course in system administration probably would be useful for you.

    Also, your posts don't ask questions, they make statements, and require that responders infer what you should be asking. Although this may be a language problem (perhaps English is not your primary language), I suggest you look over your posts, and make sure you are asking a question.

    I don't want you to be discouraged -- other responders are probably more able to understand your situation than I am. I will leave it to them.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #5
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by drl View Post
    As gently as I can: I am not altogether comfortable providing advice to you given that you do not seem to know the difference between bash and csh, and that you are running as root. That is a dangerous combination.
    It's -indeed- a dangerous combination. Csh is not the best shell I've seen and it's usage should be avoided at all cost, unless you have a good reason (and I can't think of any) to use it.

    But anyway, the key point is that, you, definitely, shouldn't be using as root any shell script that you don't understand. That's NEVER a good idea.

    The other key point is that, as you say, it's impossible to run a csh script on bash. They are different, highly different shell. In all regards: conceptually, syntactically and in which regards the grammar as well.

  6. #6
    Just Joined!
    Join Date
    Jan 2008
    Posts
    14
    First, I wish to thank you for your response and a polite way to kick me in the posterior.

    Truth is, I realize that I am missing some essential knowledge regarding the basics of Unix/Linux and programming, but that's why I ask questions at the "Newbies" section. Note - I am sorry for making statements, moreover because I did read a sticky thread for newbies regarding the info on asking questions, but I somehow forgot to ASK a question. Once more, silly me, sorry

    Also, I am aware that it is dangerous to run programs logged in as root, and I assure you that it was an isolated incident (it happened because I was editing csh.cshrc in vi - later on I remembered that it could have been done without su privileges, a merely :wq! would suffice, right?) so it won't happen again, I promise

    Now, the answer to my problem was simply invoking csh, and after that source..right? Well, that's were my next problem lies..

    Code:
    [archie.leach@localhost ~]$ csh
    dircolors: Command not found.
    sed: Command not found.
    grep: Command not found.
    cut: Command not found.
    id: Command not found.
    id: Command not found.
    [: Command not found.
    Why can't I invoke csh? I tried to invoke tcsh too, but the result was the same. After that I wasn't able to run any sort of command (such as ls, pwd, I even tried to get back to bash but with :command not found: success) untill I did an exit command.

    Please tell me that my logged-in-as-root didn't do that, and that when you said "dangerous", you didn't mean that it would do something like this.

    Note - I am using Linux at the workplace, but I pose no threat to others, because I am the only one with the distribution and it is running on a virtual machine, with Windows as a host.

    Once again, thank you for your time, and now I truly hope that I'm not dealing with a trivial problem, but a fullblooded one

  7. #7
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by archie_leach View Post
    Now, the answer to my problem was simply invoking csh, and after that source..right? Well, that's were my next problem lies..

    Code:
    [archie.leach@localhost ~]$ csh
    dircolors: Command not found.
    sed: Command not found.
    grep: Command not found.
    cut: Command not found.
    id: Command not found.
    id: Command not found.
    [: Command not found.
    Why can't I invoke csh? I tried to invoke tcsh too, but the result was the same. After that I wasn't able to run any sort of command (such as ls, pwd, I even tried to get back to bash but with :command not found: success) untill I did an exit command.

    Please tell me that my logged-in-as-root didn't do that, and that when you said "dangerous", you didn't mean that it would do something like this.

    Note - I am using Linux at the workplace, but I pose no threat to others, because I am the only one with the distribution and it is running on a virtual machine, with Windows as a host.

    Once again, thank you for your time, and now I truly hope that I'm not dealing with a trivial problem, but a fullblooded one
    If you can't run anything inside a sch instance, there might be a problem with your paths on that shell. Anyway, I really wonder why do you want to use csh instead of any other shell. It's your choice though...


    The first thing you should check is the csh man page, of course. I am by no means an expert in csh, so I can't give you comprehensive help. But according to the tcsh man page (I assume you are using tcsh which seems to be the most common csh variant these days):

    UNIX Manual Page: man 1 csh

    Startup and shutdown
    A login shell begins by executing commands from the system files
    /etc/csh.cshrc and /etc/csh.login. It then executes commands from
    files in the user's home directory: first ~/.tcshrc (+) or, if
    ~/.tcshrc is not found, ~/.cshrc, then ~/.history (or the value of the
    histfile shell variable), then ~/.login, and finally ~/.cshdirs (or the
    value of the dirsfile shell variable) (+). The shell may read
    /etc/csh.login before instead of after /etc/csh.cshrc, and ~/.login
    before instead of after ~/.tcshrc or ~/.cshrc and ~/.history, if so
    compiled; see the version shell variable. (+)

    Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on
    startup.

    For examples of startup files, please consult http://tcshrc.source-
    forge.net.
    Read the man page for more info.

    My guess is that, since most distros use bash as the default shell, they might not ship a default config for csh, and, as such, you need to define all the basic stuff yourself. Including the path. I don't have much experience with csh.

    Your best bet is to use echo $PATH on bash, copy the results, and then copy that line and use it on your .cshrc or .tcshrc files to set the path under the c shell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...