LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 11-25-2004, 08:23 PM   #1
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Rep: Reputation: 15
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?
 
Old 11-25-2004, 08:57 PM   #2
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
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
 
Old 12-07-2004, 11:59 AM   #3
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Original Poster
Rep: Reputation: 15
I still can't make this work. I'm pretty sure I've tried everything that has been suggested. What's going wrong?
 
Old 12-07-2004, 12:05 PM   #4
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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
 
Old 12-07-2004, 12:08 PM   #5
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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.
 
Old 12-08-2004, 07:56 PM   #6
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Original Poster
Rep: Reputation: 15
I get a different error message now, which is an improvement I suppose! Now I get "if: Malformed file inquiry", which is intruiging.
 
Old 12-08-2004, 08:01 PM   #7
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
try -e instead of -f...

if [ -e /etc/tcshrc ] then

Good luck,
 
Old 12-08-2004, 10:10 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Or, in tcsh syntax

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

Tink

P.S.: tcsh sucks :) ... specially for scripting.
 
Old 12-08-2004, 10:22 PM   #9
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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,
 
Old 12-09-2004, 11:54 AM   #10
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Original Poster
Rep: Reputation: 15
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!
 
Old 12-09-2004, 12:02 PM   #11
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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...
 
Old 12-09-2004, 12:42 PM   #12
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Original Poster
Rep: Reputation: 15
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!
 
Old 12-09-2004, 12:49 PM   #13
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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...
 
Old 12-09-2004, 12:59 PM   #14
boydasilva
LQ Newbie
 
Registered: Nov 2004
Location: Manchester
Distribution: Suse 10.0
Posts: 27

Original Poster
Rep: Reputation: 15
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!
 
Old 12-09-2004, 01:06 PM   #15
jeffreybluml
Member
 
Registered: Mar 2004
Location: Minnesota
Distribution: Fedora Core 1, Mandrake 10
Posts: 405

Rep: Reputation: 30
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,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GNOME - problems with menu editing and icon change VertX Linux - Software 0 04-08-2005 06:49 AM
GNOME - problems with menu editing and icon change VertX Fedora 1 04-08-2005 03:39 AM
Problems with editing proxy configurations in .bash_profile ricguitar Linux - Networking 1 07-27-2004 06:56 AM
problems editing XFree86 Nego Linux - Hardware 5 07-08-2004 03:44 AM
How to logout from .tcshrc? (never log in) BrianK Linux - General 3 04-13-2004 03:47 AM


All times are GMT -5. The time now is 04:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration