LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 02-18-2004, 03:21 AM   #1
johnstv3
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Rep: Reputation: 0
Problem with bashrc file


Hi all,

I recently installed RedHat 9.0 and all was working fine until a couple of days ago. The problem that I'm having is that whenever I start the "bash" shell the some errors are displayed and the prompt in the shell doesn't show the directory that I'm currently in. I think the problem is in the "bashrc" file within /etc and I believe I did something to it when I tried to create paths for JAVA and TOMCAT.

The errors are thrown where the "screen)" and ";;" appear in the code. I apologise for not having the error at hand but I have pasted below the actual "bashrc" file. Can anyone help me out?


Regards,

John



# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
if [ -x /usr/bin/tput ]; then
if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
elif [ -x /usr/bin/wc ]; then
if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
fi
fi
fi
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
fi
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
fi
fi
# vim:ts=4:sw=4
 
Old 02-18-2004, 05:41 PM   #2
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi

heres my bashrc file from /etc. copy it in. i'm usuing RH9 so it should be the same as your original.

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
if [ -x /usr/bin/tput ]; then
if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
elif [ -x /usr/bin/wc ]; then
if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
stty erase `tput kbs`
fi
fi
fi
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
fi
;;
screen)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
# Turn on checkwinsize
shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
fi
fi
# vim:ts=4:sw=4


before you go changing any files always make a copy of the original so you can revert back to where you started
$ cp file file.Copy
should do it.

i cant understand why you are changing the /etc/bashrc file. i thought you should change the ~/.bashrc file for path varialbles. heres mine again. with the path variable for java. again remember to relogin for all changes to take effect as this file is only read on creating a new shell.

# .bashrc

# User specific aliases and functions

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


PS1="\n\t \u [\w] -> "

alias l="ls" # long listing
alias rmi="rm -i" # remove files, prompt first
alias lf="ls -F" # long listing, displays direcories & executables only
alias p="pine" # launch Pine mail
alias rr="rm -i - r" # removes recursivly
alias lr="ls -R | less" # lists folders & subfolders/files
alias jcu="ssh -l jc144905 marlin.jcu.edu.au" # dial into JCU account
alias dfh="df -h" # disk usage, listed in Gb instead of bytes
alias word="wine /home/lee/.wine/c/Program\ Files/Microsoft\ Office/Office/WINWORD.EXE &"
alias excel="wine /home/lee/.wine/c/Program\ Files/Microsoft\ Office/Office/EXCEL.EXE &"

#####-- REMEMBER WHEN CREATING AN ALIAS, YOU MUST RE-LOGIN FOR IT TO WORK ---############

export PATH=/home/lee/j2sdk_nb/j2sdk1.4.2/bin:$PATH # environmental variable for java sdk

hope this was of use
GT
 
Old 02-19-2004, 02:20 AM   #3
johnstv3
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks GT,

I really appreciate you sending me a copy of the bashrc file that you have. When I did as you told it actually fixed the error that was constantly appearing which was excellent. Unfortunately, the bash shell still shows bash-2.05b (or something like that) at the command prompt rather than the directory that I am in.

Before the errors that I was getting files, directories, etc were shown in different colours but this lost when the errors occured. Even after having used your bashrc file the colours still are not there even though the errors are now gone. As I'm a beginner with Linux (running under KDE) I have no idea what I've done or what is wrong. Could there be something wrong in the /etc/profile file or is it some other issue? Any help is much appreciated.


Regards,

John
 
Old 02-19-2004, 05:39 PM   #4
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi

good to hear the files where of use. as far as where we go from here, i have to know what else you have changed. have you modified the /etc/profile file as well?? i'm also a beginner, so it's a bit like the blind leading the blind. but if i know which files you have modified i can send you copies of mine. i'm led to beleive that the only file you should modify are the ones in your home directory as these are read last as the shell is loading. to see them type
$ l.
or 'view -> show hidden files' in the browser, all the hidden file begin with a dot. the .bashrc is the most relevant i think.
regards
GT
 
Old 02-20-2004, 02:34 AM   #5
johnstv3
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Hi GT,

I did indeed chang the /etc/profile but I only did so because the JAVA_HOME changes didn't seemed to work in bashrc. It was then I decided to put the JAVA_HOME, CLASSPATH, etc into /etc/profile instead. To my surprise it worked but the side effect were the shell problems I experienced. It could be that I deleted something by mistake but I have no idea for sure. It seems now that I've realised that I should have been using ~.bshrc in my root directory rather than the orignal files. As far as I can remember /etc/profile was the only file that I changed in addition to bashrc. Thanks again fo your help.


Regards,

John
 
Old 02-21-2004, 01:26 AM   #6
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi john

somehow, reading between the lines i knew you'd changed the /etc/profile file. the joys of tinkering eh?!?!?! it's been a steep learning curve for me these past 2 months learning a new OS. if it makes you feel any bettter, i've had to re-install 4 times due to major fu@k ups on my behalf. anyway enough waffle heres the /etc/profile file you requested:-

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|$1($|" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done

unset i


thats it in its entirity. i hope this is of use to you. take some time to look at my ~/.bashrc posted earlier in the thread, as it shows how to set up a PATH variable. you'll obviously have to alter the absolute file path to reflect where on the system your java bin files are. once the .bashrc file is updated, re-login with
$su - your_login_name
then type at the prompt to see if the system found your java files:
$ java -version
this should print back to the screen info about the version your using, heres mine for comparison:
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java Hotspot(TM) Client VM (build 1.4.2-b28, mixed mode)

if anything like this (obviously with your version etc) is printed to the screen it means everything is hunky dory. happy java-ing. if it tells you that the java command is not found we need to go further. regards
GT
PS i hope this all makes sense, as it's late Saturday afternoon and the days been hot and sweaty. consequently i've been on the grog all afternoon with some mates and i'm half cut. :-)
PS PS
if you need to tinker with a profile file tinker first with the ~/.bash_profile file, and only after making a copy.
 
Old 02-21-2004, 01:34 AM   #7
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hey john

sorry for the smiley heads, not my fault, the LinuxQuestions.org software seems to be interpreting certain collections of characters and converting them into smilies. i'll presume you haven't tinkered with these lines so you should be okay if you just copy and paste from the line below them. if not successful let me know your e-mail and i'll attach the text file. sorry for that pal. technology eh, where would we be without it!?!?!?!?
regards
GT
 
Old 02-24-2004, 02:21 AM   #8
johnstv3
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks GT,

Thanks very much for sending me a copy of the profiles file. I copied and pasted as you told me to do and rebooted Linux. Unfortunately nothing has changed. The bash-2.05b is still shown instead of the login name/directory and no colours are being shown in the shell. I simply don't know whats happened? If there's any other advice you could give me then that would be great. Otherwise your help has been much appreciated.


Regards,

John
 
Old 02-24-2004, 11:14 PM   #9
globeTrotter
Member
 
Registered: Feb 2004
Location: Townsville, Queensland, Oz
Distribution: Red Hat 9
Posts: 107

Rep: Reputation: 15
hi john

glad to be of help, pity i can't be of more help. usually it's a case of backtracking, but as i said, i've already re-installed 4 times. i'm finally getting the hang of it. Why not back up all files and re-install your's??!! failing a guru coming up with a solution, it might be your only option. whatever you do, have fun with it eh.
regards
GT
 
Old 02-25-2004, 12:56 AM   #10
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Two warnings: not a guru - I'm an idiot. And jeez, RH scripts are awful. What I say may not be applicable to RH as I use Slack, but...

For colors, I copy /etc/DIR_COLORS to ~/.dir_colors, edit to taste, and add
eval `dircolors -b ~/.dir_colors`
to my ~/.bash_profile.

For PS1, I put a complicated mess, the relevant part of which is just
export PS1='whatever I want, such as \w'

And my ~/.bashrc is a symlink to ~/.bash_profile because I don't give a flip about which is which. That avoids a lot of issues.

If RH is doing something weird, you can try to circumvent it by hacking at all the files but that got you into trouble to begin with, so you might just create a 'myshell' wrapper to invoke at startup and specify where bash is to look for its configs if RH somehow messed that up.

bash --rcfile ~/.bashrc

Utterly redundant under ordinary circumstances, but maybe RH has already redefined it further up the config chain. That's a really dumb and maybe not workable suggestion, but I can't think why bash wouldn't pay attention to your configs, which do seem to set /w as PS1.

As far as making changes take effect, you shouldn't have to reinstall or reboot or even re-login. If I change ~/.bash_profile and want it to take effect, I type '. ~/.bash_profile' and bash rereads it.

As far as the smilies, there's an option to disable them for any post that's going to have a character sequence that will trigger them.
 
Old 02-26-2004, 02:09 AM   #11
johnstv3
LQ Newbie
 
Registered: Feb 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Hi GT,

I'll play around and see what I can do. Thanks for all the help you've given me. Very much appreciated.


Regards,

John
 
  


Reply



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
reloading .bashrc file blackzone Linux - Newbie 8 03-02-2013 10:58 AM
Bashrc file Gins Linux - General 19 09-06-2005 03:19 PM
can't the file bashrc Paxmaster Linux - Software 10 01-02-2005 06:58 AM
where is the .bashrc file??? xenia Linux - Newbie 8 05-08-2004 12:11 PM
bashrc file Linvilidiot Linux - Newbie 3 03-11-2004 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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