.tcshrc --> ":Command not found." message

Discussion in 'General Mac Discussion' started by Crooked Finger, Feb 7, 2004.

  1. Crooked Finger macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #1
    any entries (even blank lines) in my .tcshrc file produce the above message when i source the file or open a new shell. same thing happens if i use bash and a .bash_profile file.

    only thing I've tried that doesn't produce an error is:
    echo 'hello'

    thanks.
     
  2. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #2
    That's very odd. Did you previously use Terminal without this symptom, and it just started happening, or has it always happened since you first tried Terminal?

    Also, please type the command
    Code:
    echo $SHELL
    and let's see if the output is
    Code:
    /bin/tcsh
    as one would expect.
     
  3. Crooked Finger thread starter macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #3
    Also, please type the command
    Code:
    echo $SHELL
    and let's see if the output is
    Code:
    /bin/tcsh
    as one would expect. [/B][/QUOTE]

    it returned:

    /bin/bash

    i have changed the pref's to run /bin/tcsh and i've done this from the command line, as well, and afterwards i still get the /bin/bash after i type "echo $SHELL"

    i don't know if i've had this problem always, b/c i just started attempting to create some aliases, and that's when i noticed the difficulty.
     
  4. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #4
    This is still a mystery, so we should take it one step at a time. Which version of Mac OS X are you running? In Terminal Preferences, is it set to "Execute the default login shell using /usr/bin/login" or is it set to "Execute this command"? What command is filled in? What terminal type? And is the "Open a saved .term file" checkbox checked and a value filled in?
     
  5. Crooked Finger thread starter macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #5
    (thank you for your help...)

    OS 10.3.2

    I've tried both "execute" options in terminal preferences. I've switched it to execute this command: /bin/tcsh

    terminal type: vt102

    the "Open a saved .term file" box is checked and the file is: ~/Documents/vt102term.term

    i must have changed something. now with only the following in a .tcshrc file:

    alias ll 'ls -l'

    I don't receive an error when opening a new shell, but when I type "ll" I receive the following:

    ls: illegal option --
    usage: ls [-ABCFGHLPRSTWZabcdfghiklnoqrstuvx1] [file ...]

    (if there's a an additional blank line i still get the ": Command not found" error upon opening a new shell.)

    regards.
     
  6. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #6
    why don't you do this. Open a terminal window. Type

    ps

    then type:

    cat .cshrc

    and

    cat .tcshrc

    they copy everything and paste it here.

    The ps will show us which shell you are running and the we can look at exactly what your prefs files look like.

    Here is mine:

    [Titan:~] phill% ps
    PID TT STAT TIME COMMAND
    1408 std Ss 0:00.08 -tcsh
    [Titan:~] phill% cat .cshrc
    source /sw/bin/init.csh
    setenv DISPLAY :0.0
    setenv PATH ~/bin:/Library/MySQL/bin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:$PATH
    setenv EDITOR vi
    alias scanelite "nmap -P0 -oG /Users/phill/Desktop/nmapout.txt -p 31337 -n -T 5 1"
    alias nmapp "nmap -p 1-65535"
    alias psa "ps -auxw | grep -v '0.0 0.0 0 0' | grep -v ssh | grep -v tcsh | grep -v mingetty"
    alias gwhois "whois -h geektools.com"
    alias starwars "telnet towel.blinkenlights.nl"
    alias today "cat /usr/share/calendar/* | grep `date +"%m/%d"`"
    [Titan:~] phill% cat .tcshrc
    cat: .tcshrc: No such file or directory
    -----
    So I am running tcsh
    I have set my display, path, and editor shell variables, I have a few alias's. I have no .tcshrc file

    When you said that you had "teminal type: vt100" that is clearly wrong. The shell will try to find a command "terminal" in your path. And if it found one, it would use the arguements "type:" and "vt100" You can type

    which terminal

    to see that there is nothing.
     
  7. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #7
    It seems to be acting as if you are in one shell while trying to follow the conventions of another shell. !?

    Since you have the line
    Code:
    source /sw/bin/init.csh
    in your .cshrc file, please show us the contents of file /sw/bin/init.csh too.

    One way to study the problem might be to rename .cshrc to .cshrc.save and create a new .cshrc containing only the line
    Code:
    echo "Hello from .cshrc"
    See if you get any error message when you open a Terminal window. If not, you can add the lines from .cshrc.save back into .cshrc, one at a time, and see where things start to go wrong.
     
  8. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #8
    I don't have the problem... I am not the thread starter, but another helper like yourself.

    The init.csh is needed for fink. Fink is normally installed in the /sw directory.
     
  9. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #9
    Sorry. I wasn't paying close enough attention.
     
  10. janey macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #10
    hey...what did you do to set tcsh as your default shell? It should have been something like
    Code:
    chsh -s /bin/tcsh (your username)
    anyways, why do you prefer using tcsh? bash is so much nicer...
    did you also try stuff in ~/.bash_profile, ~/.bash_login and ~/.profile?
     
  11. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #11
    I can't stand bash, sorry... I set tcsh as my shell in the terminal application preferences. Very simple...
     
  12. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #12
    bash is better than plain ol' sh, but i still prefer csh or tcsh, maybe just because I've used csh for years. i use ksh on other platforms, but i'll stick with tcsh for Mac OS X. But I write all shell scripts in sh/ksh/bash. for me, csh and tcsh are stricly for interactive use.
     
  13. Crooked Finger thread starter macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #13
    Here are those commands:

    Code:
    Dagobah:~] paul% ps
      PID  TT  STAT      TIME COMMAND
     1641 std  Ss     0:00.04 -tcsh
    [Dagobah:~] paul% cat .tcshrc
    alias   ll      'ls -l'
    [Dagobah:~] paul% cat .cshrc
    cat: .cshrc: No such file or directory
    

    I would be fine with bash. As you can tell, I'm not experienced enough to worry about any differences (and likely will never be). I'm interested, but I only started a .tcshrc (or .bash_profile, etc) file b/c I wanted to be able to save aliases, and then I noticed the weird behavior. (recall, I couldn't get this to work with bash and the .bash_profile, either). ((also, i use tcsh at school)) anything that works is fine with me, tho.

    I am wondering if there are hidden (tho I don't see them in vi) eol characters that might be messing up the alias command in the .tcshrc file. Hence the "illegal option" error I got above, and the ": Command not found" messages.

    Why do I get:

    [Dagobah:~] paul% echo $SHELL
    /bin/bash


    when the process is running tcsh and I've set the /bin/tcsh file to be executed upon opening a new shell?

    thanks!
     
  14. encro macrumors 6502

    encro

    Joined:
    May 6, 2002
    Location:
    bendigo.victoria.au
    #14
    You are using the wrong syntax for making an alias with the bash shell.

    /bin/bash is:
    alias ll='ls -la'

    /bin/tcsh is
    alias ll 'ls -la'

    Minor change by adding the equal (=) sign. tcsh is a better shell but bash is easier because there is a lot more information geared towards a simple linux install.

    If it doesn't concern you in regards to your shell environment just use 10.3's default and create a ~/.bash_profile file instead.
     
  15. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #15
    Okay, that is kind of crazy. Your PS command shows that you are running tcsh. Can you verify your Terminal App -> Preferences and tell us what options are selected...

    I am using execute this app
    /bin/tcsh
    and using a vt100 declaration

    why don't you do this...

    mv ~/.tcshrc ~/.cshrc

    I would also edit your .cshrc to remove the spaces.

    alias ll 'ls -l'
     
  16. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #16
    To find out if you have hidden characters or incorrect line terminators, you can use the od command, e.g.,
    Code:
    od -c .tcshrc
    The "-c" switch means to display the actual characters where possible, as opposed to the numeric byte values. So this command will show you each character, spaced out. \n means linefeed and \r means carriage return. Ignore the offset values at the left margin.

    If you are suspicious about your .tcshrc file, however, you could simply delete the file and recreate it from scratch in TextEdit.
     
  17. janey macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #17
    Nooooo! vim is so much better :D
     
  18. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #18
    Ooooh! Let's have a fistfight about it! Care to step outside? :)

    Actually, of course, you can use any text editor you like for simple tasks like creating a file with a couple of lines in it. You can even do it without a text editor:
    Code:
    rm .cshrc
    echo "alias list ls" >.cshrc
    echo "alias delete rm" >>.cshrc
    When you have more complicated editing to do, you can pick a text editor based on sophistication, flexibility, and familiarity. We can argue about those tradeoffs until the dogcows come home!

    I use vi and TextEdit back and forth and sometimes get confused because I forget which window is which, and it serves me right!
     
  19. Crooked Finger thread starter macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #19
    OK. I did those things:

    Code:
    [Dagobah:~] paul% ps
      PID  TT  STAT      TIME COMMAND
      466 std  Ss     0:00.04 -tcsh
    [Dagobah:~] paul% cat .cshrc
    alias ll 'ls -l'
    [Dagobah:~] paul% ll
    ls: illegal option -- 
    usage: ls [-ABCFGHLPRSTWZabcdfghiklnoqrstuvx1] [file ...]
    [\code]
    
    (removing spaces, too).  In preferences, I'm running /bin/tcsh (tried /bin/csh, too)  and set my terminal to vt100.
    
    whatever.  i feel i'm taking too much time away from people who would otherwise be fighting crime or curing disease.  thanks for the help (Q, PHILL, et al)
     
  20. Crooked Finger thread starter macrumors newbie

    Joined:
    Feb 7, 2004
    Location:
    Seattle
    #20
    resolution

    I noticed that when I was creating files in vi, it was putting a [dos] tag on the bottom of the file when I'd :wq and exit. I was opening a .term file that maybe had something weird in it each time. When I unchecked this in "prefs" and recreated the .cshrc file, this [dos] format was lacking. indeed, the dos format was putting '\r' characters at the end of the lines. weird. i don't know how to actually toggle that mode (of writing files in "dos" format), but now i can at least have a working set of aliases. thanks for the help!
     
  21. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #21
    I'd hate to give up on you. I already fought 7 crimes and cured 11 diseases today (and I took out the garbage too), so I'll give you one more idea. When a program is acting foolishly, erase its preference file so it'll start clean. In this case, while Terminal is not running, erase file /Users/yourname/Library/Preferences/com.apple.Terminal.plist. Maybe that will help.
     

Share This Page