Editing .tcshrc problems
I don't seem to be able to make this work. I've switched to tc shell and made a .tcshrc file, which looks a bit like this:
################################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if [ -f /etc/tcshrc ]; then . /etc/tcshrc endif ################################################################ Now when I open a shell, i get this message: if: Expression Syntax. What's wrong with my if statement? Have I missed something out? Also, I need to add these statements to the .tcshrc in order to get a program to run: setenv LD_LIBRARY_PATH $HOME/EMAN/lib set path = (. $HOME/EMAN/bin $HOME/bin /bin) But when I add these to the .tcshrc nothing changes. What exactly am I doing wrong? |
When you make changes to the .tcshrc file, you need to run the command
Code:
source ~/.tcshrc I hope this helps --Ian |
I still can't make this work. I'm pretty sure I've tried everything that has been suggested. What's going wrong?
|
I'm no pro here, but I think the problem is the ";" after the first line of the statement. Remove that and add "source" to the command.. Now it will look like:
################################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if [ -f /etc/tcshrc ] then source /etc/tcshrc endif ################################################################ If that still doesn't work, try changing the "endif" to "fi" instead. Hope this helps, good luck, Jeff |
Wait, I think I found the problem. Use () instead of []. Just did a test and got the same message when I used the [] - no error when I used the ()
Good luck. |
I get a different error message now, which is an improvement I suppose! Now I get "if: Malformed file inquiry", which is intruiging.
|
try -e instead of -f...
if [ -e /etc/tcshrc ] then Good luck, |
Or, in tcsh syntax
Code:
if ( filetest -e file) source /etc/tcshrc Tink P.S.: tcsh sucks :) ... specially for scripting. |
Oh, and my example is wrong...I copied and pasted and kept the brackets when I should have used parenthesis...as in...
if ( -e /etc/tcshrc ) then Good luck, |
I now have:
################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if ( filetest -e file ) source /etc/tcshrc endif setenv LD_LIBRARY_PATH $HOME/EMAN/lib set path = (. $HOME/EMAN/bin $HOME/bin /bin /etc) ################################################ And I'm back to the "if: expression syntax" error message. Some of you may have realised by now that I am rubbish at this kind of thing. All I really want to do is add the path and setenv lines at the bottom of my script so that i don't have to type them in every time I run the program. I feel I have to use tcsh 'cos that's what I'm on at university and I understand bash even less (if that's actually possible!). If anyone still feels they want to help me then that's very much appreciated, but I understand if you'd rather do something else! |
Try it this way...
################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if (-e /etc/tcshrc) then source /etc/tcshrc endif setenv LD_LIBRARY_PATH $HOME/EMAN/lib set path = (. $HOME/EMAN/bin $HOME/bin /bin /etc) ################################################ and if that doesn't work, try ################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if (-e /etc/tcshrc) source /etc/tcshrc endif setenv LD_LIBRARY_PATH $HOME/EMAN/lib set path = (. $HOME/EMAN/bin $HOME/bin /bin /etc) ################################################ and let us know if that works... |
The top one works. thanks very much. I'm sure I tried that earlier.
However, (perhaps I should have seen this one coming) because I have changed path and environment variables, I've now lost the use of my editor, commands like "less", and basically everything else that's useful. Sorry! |
perhaps, instead of "set path" you should use export PATH
I'm not very good with this stuff, but try this: ################################################ # .tcshrc # User specific aliases and functions alias rm 'rm -i' alias cp 'cp -i' alias mv 'mv -i' # Source global definitions if (-e /etc/tcshrc) then source /etc/tcshrc endif setenv LD_LIBRARY_PATH $HOME/EMAN/lib PATH=$PATH:$HOME/bin:$HOME/EMAN/bin:/bin:/etc:/sbin:/usr/sbin export PATH ################################################ That will not only add the new path you want, but a couple others I find useful (/sbin & /usr/sbin) I'm pretty sure this will work now. I think you just over-wrote your usual path settings with the set path command. Good luck, let us know if it works... |
I get a "bad : modifier in $ ($)" message. I think that the export path statement there is bash syntax. I'll have a look at it. Thanks for helping though! Much appreciated!
|
Sorry.
Did you see the reply to your other post? You may try replacing the two lines for setting the path with this one from your other post... setenv $PATH:$HOME/EMAN/bin:$HOME/bin:/bin:/etc and try that. Hat tip to bostontech for that suggestion... Good luck, |
All times are GMT -5. The time now is 12:04 AM. |