LinuxQuestions.org
Visit Jeremy's Blog.
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 12-11-2009, 12:21 AM   #1
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Rep: Reputation: 15
bash profile setting


hi,

i tried to set the apache home in red hat.we have two apache home one is default and another one is istalled newly.
we create the user apache.

bash_profile

echo please type the apache home
read c
a=new
if $c=$a
then
export APACHE_HOME=/usr/local/apache2
PATH=$PATH:$APACHE_HOME/bin
else
export APACHE_HOME1=/etc/httpd
fi

we got the following errors

please type the apache home
new
-bash: new=new: command not found

is it possible to set the two apache homes in same bash profile.
 
Old 12-11-2009, 12:36 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
This should solve your problem -- change the line
Code:
if $a=$c
to
Code:
if [ "$a" = "$c" ]
 
1 members found this post helpful.
Old 12-11-2009, 12:41 AM   #3
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Tests need to be in square brackets '[]'

eg.
if [ $c = $a ]
then
# do something

fi

I usually put strings in double quotes and leave numbers bare

eg
STRING1="some garbage"
if [ "$STRING1" = "hello" ] ....

COUNT=5
if [ $COUNT -eq 7 ] ...

Please note there are different types of tests depending on the data types, here's a reference:
http://www.oreillynet.com/linux/cmd/cmd.csp?path=t/test

cheers

Last edited by kbp; 12-11-2009 at 12:42 AM. Reason: typo
 
1 members found this post helpful.
Old 12-11-2009, 01:37 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,417

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Double brackets [[ ]] is more robust http://tldp.org/LDP/abs/html/testcon...ml#DBLBRACKETS
 
1 members found this post helpful.
Old 12-11-2009, 01:44 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
What kpb wrote except [[ ]] is preferred for testing over [ ].
 
  


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
Slackware bash profile ibwew Slackware 10 09-13-2009 01:36 PM
Bash Profile ...... babujd Linux - Newbie 16 07-23-2009 07:25 PM
screen bash profile? true_atlantis Linux - Software 3 06-26-2009 02:45 PM
/etc/profile vs. /etc/bash.bashrc jbrashear Debian 3 03-11-2004 04:49 PM
where is my bash profile? bandofmercy Linux - General 3 04-08-2003 06:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:46 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