LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-21-2004, 02:21 PM   #1
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Rep: Reputation: 15
shell behaves differently in rl5 and rl3


Hi I'm running rh9.0 and at the moment I am playing with sed. I have put a function in my .bash_profile so that it would be available and not have to be declared every session. However the function only runs in rl3 at the shell prompt
In rl5 typing in the function name and arguments just returns me to the prompt no error message nothing. In rl5 I'm using xterm and rh default terminal program.

any help appreciated.

WD
 
Old 09-21-2004, 02:54 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
G'day mate :}

Create a .bashrc and source .bash_profile from there.

Alternatively, invoke as "xterm -ls" to make it a login
shell ... if you want to understand why, read
Code:
man bash
/INVOCATION


Cheers,
Tink
 
Old 09-21-2004, 03:38 PM   #3
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
thanks Tink, is there a way to set bash to start with "bash --login" so I dont have to type it in every time? same with xterm -ls.

Can I put "bash --login" in my .bashrc file?

WD

Last edited by Warmduvet; 09-21-2004 at 03:39 PM.
 
Old 09-21-2004, 04:19 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,082

Rep: Reputation: 299Reputation: 299Reputation: 299
You could do that, but I personally just redirect my .bash_profile to .bashrc -- the following are the contents of my .bash_profile:

Code:
if [ -r ~/.bashrc ]
then
  . ~/.bashrc
fi
and then I put all of my customized setup stuff into my .bashrc file. This way it gets run regardless of whether or not I'm invoking a login shell.
 
Old 09-21-2004, 04:43 PM   #5
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Yeah I have something similar in my .bash_profile

if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi

Last edited by Warmduvet; 09-21-2004 at 04:51 PM.
 
Old 09-21-2004, 05:02 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
You need it the other way round mate, since
.bash_profile won't be pulled if it's not a login
shell which in your case it isn't.


If it's NOT a login-shell bash only evaluates
~/.bashrc



Cheers,
Tink
 
Old 09-21-2004, 07:04 PM   #7
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
slight problem, I put "bash --login" in my .bashrc file and now I can't login as root

nor can I su - root from other user any suggestions...
yes I know I shouldn't have been working in root

my .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:$HOME/bob/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH
function testfind ()
{
echo "first argument: $1"
echo "second argument: $2"
sed -n "/$1/p" $2
}

My .bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls --color=yes'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

bash --login



WD

Last edited by Warmduvet; 09-21-2004 at 07:13 PM.
 
Old 09-21-2004, 07:12 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Boot into single user mode and edit it from there ...

If that fails, boot of CD (rescue mode).

Other (possbile) work-around:

su -c "mv ~/.bashrc ~/.bashrc.bad"


Cheers,
Tink

Last edited by Tinkster; 09-21-2004 at 07:13 PM.
 
Old 09-21-2004, 07:15 PM   #9
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
booting to rl3 doesnt work can't login as root

dont I need to be root to do the mv?
 
Old 09-21-2004, 07:17 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Just try it :) It's all one line!


I won't f*ck up root account just to verify that
it works ;}


Cheers,
Tink
 
Old 09-21-2004, 07:22 PM   #11
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
LOL

OK it worked

still leaves me with ny original problem... and both .bashrc and .bash_profile

have

if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi

so it shouldn't matter wether the shell is interactive or login

WD

Last edited by Warmduvet; 09-21-2004 at 10:15 PM.
 
Old 09-21-2004, 07:38 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
OK, let's get that straight ...

:}


You need to source .bash_profile
from .bashrc for the modifications in
.bash_profile to be working in the xterm.

Sourcing .bashrc from both .bashrc and
.bash_profile won't give you any benefit.

If it's not a login shell .bash_profile won't
be pulled at all.


Cheers,
Tink

P.S.: I think I definitely deserve an affero after all this ;)
 
Old 09-21-2004, 09:15 PM   #13
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
OK affero done.

I understand what you mean by source .bash_profile and why,
I,m not sure how.
Do I replace...


in .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

with

# Source global definitions
if [ -f ~/.bash_profile ]; then
~ /.bash_profile
fi

???

WD
 
Old 09-21-2004, 10:07 PM   #14
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Got that right :)


Cheers,
Tink
 
Old 09-22-2004, 12:09 AM   #15
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Ok I tried..

# Source global definitions
if [ -f ~/.bash_profile ]; then
. ~ /.bash_profile
fi

no luck, and login failed
and..

source ~/.bash_profile

no luck, and login failed
and..

ln -s /home/bob/.bashrc /home/bob/.bash_profile

this gave message ln : `/home/bob/.bash_profile': file exists
but login didn't fail but also didn't achieve desired result.

I have done quite a bit of googling and this seems to have been aproblem
for a few people but the solution never seems to be arrived at

WD
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla working differently! redhatrosh General 2 05-04-2005 12:29 AM
applet on linux server behaves differently naijaguy Programming 3 01-07-2005 02:09 PM
Configuring the way mandrake 9.2 looks/behaves.. tinaldor Mandriva 7 11-14-2003 04:49 AM
pppd behaves strange Castor Linux - Networking 3 09-24-2003 08:12 AM
XMMS runs differently with different users infamous41md Linux - Newbie 8 05-18-2003 06:05 AM


All times are GMT -5. The time now is 01:14 AM.

Main Menu
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