LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-10-2009, 11:21 PM   #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-10-2009, 11:36 PM   #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-10-2009, 11:41 PM   #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-10-2009 at 11:42 PM. Reason: typo
 
1 members found this post helpful.
Old 12-11-2009, 12:37 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Double brackets [[ ]] is more robust http://tldp.org/LDP/abs/html/testcon...ml#DBLBRACKETS
 
1 members found this post helpful.
Old 12-11-2009, 12: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



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

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

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