LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Editing .tcshrc problems (https://www.linuxquestions.org/questions/linux-newbie-8/editing-tcshrc-problems-259332/)

boydasilva 11-25-2004 07:23 PM

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?

IBall 11-25-2004 07:57 PM

When you make changes to the .tcshrc file, you need to run the command
Code:

source ~/.tcshrc
to make the changes take effect in the current shell. You can also close the shell and open a new one. This hopefully will sort the environment variable problem.

I hope this helps
--Ian

boydasilva 12-07-2004 10:59 AM

I still can't make this work. I'm pretty sure I've tried everything that has been suggested. What's going wrong?

jeffreybluml 12-07-2004 11:05 AM

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

jeffreybluml 12-07-2004 11:08 AM

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.

boydasilva 12-08-2004 06:56 PM

I get a different error message now, which is an improvement I suppose! Now I get "if: Malformed file inquiry", which is intruiging.

jeffreybluml 12-08-2004 07:01 PM

try -e instead of -f...

if [ -e /etc/tcshrc ] then

Good luck,

Tinkster 12-08-2004 09:10 PM

Or, in tcsh syntax

Code:

if ( filetest -e file) source /etc/tcshrc
Cheers,

Tink

P.S.: tcsh sucks :) ... specially for scripting.

jeffreybluml 12-08-2004 09:22 PM

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,

boydasilva 12-09-2004 10:54 AM

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!

jeffreybluml 12-09-2004 11:02 AM

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...

boydasilva 12-09-2004 11:42 AM

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!

jeffreybluml 12-09-2004 11:49 AM

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...

boydasilva 12-09-2004 11:59 AM

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!

jeffreybluml 12-09-2004 12:06 PM

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.