LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 04-01-2011, 05:44 AM   #1
New2LQ
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Rep: Reputation: 0
Unhappy bash will not allow me to enter tcsh


OK, I'm so lost it's difficult to even pose my question. My default shell is bash; and I'd like [actually, required to] have the ability to type csh and enter the TC shell...but it's not working at all. All the changes I made to the ~/.bashrc file work great, but I can't seem to access tcsh to see if the commands in my ~/.tcshrc file work.

When I type "csh", my old PS1 [prompt] displays and I have to type "exit" to get back to the one in the bashrc file and then type "bye" to log out off the system.

I've spent the last 3 days researching this, but every article/blog/site discusses permanently changing my log in...NOT going to happen. As you see, I need all the help anyone can give.

Thank you ahead of time.
 
Old 04-01-2011, 06:02 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Sincerely it's not clear what the problem is. The csh executable is a link to /bin/tcsh on recent systems. If the csh command runs without problems and it actually starts a tcsh session, the file ~/.tcshrc should be sourced accordingly. You may try to put an echo statement inside it to verify.
 
Old 04-01-2011, 07:09 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
Not all Linux OS will display a different prompt.
RHEL, CentOS, Fedora, PCLinuxOS, Mandriva : No.

Slackware, Debian, Ubuntu : A "%" prompt.

http://www.linuxquestions.org/linux/...Ask_a_Question
http://linuxsilo.net/docs/smart-questions_en.html
 
Old 04-01-2011, 07:34 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Look at the /etc/shells file. Is sch or tsch listed?
If you want to change shells, you can use the chsh command to change your login shell.

You should be able to enter a shell in bash. At that point you are using the other shell in a subshell.
Maybe it isn't installed.
 
1 members found this post helpful.
Old 04-02-2011, 01:27 AM   #5
New2LQ
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jschiwal View Post
Look at the /etc/shells file. Is sch or tsch listed?
If you want to change shells, you can use the chsh command to change your login shell.

You should be able to enter a shell in bash. At that point you are using the other shell in a subshell.
Maybe it isn't installed.
Thanks for this info...I just checked and both "/bin/csh" and "/bin/tcsh" files are there...so it seems I'm good there. I'm just not sure how to get my newly created ~/.tcshrc file to work...meaning which one should I stick in the test like the following code at the beginning of my .bashrc file:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
I think that's the problem I have seeing that I have accessed the TC shell; I don't have a test, so my .tcshrc file isn't getting accessed. Does this explain a little more? And if so, can you help?
 
Old 04-02-2011, 03:47 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by New2LQ View Post
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
I think that's the problem I have seeing that I have accessed the TC shell; I don't have a test, so my .tcshrc file isn't getting accessed. Does this explain a little more? And if so, can you help?
The test in ~/.bashrc is there because the file /etc/bashrc (the system-wide configuration - for all the users) is not one of the files sourced by the shell when invoked (I mean it is not sourced by default, since it's not hard-coded in the bash functionality). The bash shell uses /etc/profile, then looks for configuration files in the user's home directory. This is the reason of the test you mentioned. Anyway I don't see in which way this is related to your issue.

If I understand well, the problem is that the file ~/.tcshrc is not sourced whenever a C-shell session is started, right? What is the actual content of the ~/.tcshrc? What does it make you guess it's not sourced? Have you tried to put an echo statement inside it to verify?
 
Old 04-02-2011, 07:50 PM   #7
New2LQ
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
The test in ~/.bashrc is there because the file /etc/bashrc (the system-wide configuration - for all the users) is not one of the files sourced by the shell when invoked (I mean it is not sourced by default, since it's not hard-coded in the bash functionality). The bash shell uses /etc/profile, then looks for configuration files in the user's home directory. This is the reason of the test you mentioned. Anyway I don't see in which way this is related to your issue.

If I understand well, the problem is that the file ~/.tcshrc is not sourced whenever a C-shell session is started, right? What is the actual content of the ~/.tcshrc? What does it make you guess it's not sourced? Have you tried to put an echo statement inside it to verify?
Well, when you code a ~/.XXshrc file, you have to test for the existence of its default profile. Once you know it's there, then you have the shell read your personally designed profile...which would be the ~/.XXshrc.

To answer your question, here's the code for my ~/.tcshrc file:
# .tcshrc
# Source global definitions
if (-f /etc/tcsh) then
. /etc/tcshrc
endif
# User specific aliases and functions
alias rm 'rm -i' #always checks prior to removing a file
alias cp 'cp -i' #always checks prior to copying a file
alias mv 'mv -i' #always checks prior to moving or renaming file
alias lal 'ls -a --color=tty' #required alias
alias bye 'exit' #exiting the TC shell back to bash
set savehist = 150 #saves 150 commands
set
prompt = '[%n@-tcsh%~]%# ' #distinguish prompt form bash
Now it works!!! I was just over-thinking the whole thing. All I had to do was change "bash" to 'tcsh' and revamp the if-statement to 'endif' and now I'm in the tcsh subshell from my bash shell. Thanks to all of you that responded...many were helpful in getting me to think!

Last edited by New2LQ; 04-02-2011 at 07:53 PM.
 
Old 04-03-2011, 03:33 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by New2LQ View Post
Well, when you code a ~/.XXshrc file, you have to test for the existence of its default profile. Once you know it's there, then you have the shell read your personally designed profile...which would be the ~/.XXshrc.
Of course. But the default profile name not necessarily is equal to the personal one (without the leading dot). Anyway, every shell's man page describes the behaviour at invocation and lists the related configuration files. I cannot find any mention of /etc/tcshrc in the man page of tcsh and I've never heard about that, despite I've used it a lot on Unix machines.
Quote:
Originally Posted by New2LQ View Post
# Source global definitions
if (-f /etc/tcsh) then
. /etc/tcshrc
endif
Just a glitch in this code: it should be -f /etc/tcshrc.
 
  


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
tcsh shell to bash jhwilliams Linux - General 1 05-17-2007 12:56 PM
I use tcsh and I have bash ?????? grizos Linux - General 2 11-21-2005 10:50 PM
bash vs tcsh versioning ? puishor Programming 7 08-29-2005 10:29 PM
TCSH vs. BASH Imyrryr Linux - General 3 09-13-2003 04:33 PM
bash or tcsh infected Linux - General 2 06-17-2003 01:17 PM


All times are GMT -5. The time now is 12:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration