LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-14-2004, 03:01 PM   #1
louisb
Member
 
Registered: Aug 2003
Posts: 199

Rep: Reputation: 15
PATH Scripting


I'm new to Linux and trying to add additonal directories to my environment. i have create a command file/script to just at additional directories to my environment as follows:

echo "Entering java paths"

PATH=$PATH:/usr/java/j2sdk1.4.2_03
PATH=$PATH:/usr/java/j2sdk1.4.2_03/bin
PATH=$PATH:/usr/java/j2sdk1.4.2_03/jre
PATH=$PATH:/usr/java/j2sdk1.4.2_03/lib
PATH=$PATH:/usr/java/j2sdk1.4.2_03/include
export PATH
PATH=$PATH

echo $PATH
echo "Leaving java path"

If key the commands in a terminal window they are applied to my environment. If I place these command in a file and execute them they are not. I use "env" to check enviroment and the "PATH" variable does not show the directories added. However, if I enter them by hand and then do an "env" they do show up. Can anyone tell me what's happing?

I've add the command to my startup profile and they work just fine. I would really like to execute them from a command file. I'd like to have a command file for each application environment to be executed from a command file. I really want them to be functions that I can use any where I like.
 
Old 01-14-2004, 03:25 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
When you put the commands in a file, are you sourcing it? For example,
. ./file-with-commands.sh

Or are you just running them in a shell script? If you are just putting them in a script, the values will reset when the shell exits.

Also, why are you adding all of those directories to your PATH? There are no binaries in include or lib.
 
Old 01-14-2004, 04:30 PM   #3
louisb
Member
 
Registered: Aug 2003
Posts: 199

Original Poster
Rep: Reputation: 15
Thanks for your help I was not source the file properly. I was only using the following: "./filename" when i changed it to ". ./filename" it worked just fine. However, I do have another question. Shoudn't "lib" and "include" be include in the path to ensure that the application knows where everything is located that it may need?

I appreciate your feed back.

Thanks

Louis
 
Old 01-14-2004, 11:19 PM   #4
benjithegreat98
Senior Member
 
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
No. If you just want the javac, java, etc commands then you just need to put the ...../bin dir in the path. When you run the program it knows where everything else is. It knows where to search for files without you giving it a path for the "extra stuff." If there are other executables that you will actually use then you should include those dirs as well.
 
Old 01-14-2004, 11:20 PM   #5
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"Shoudn't "lib" and "include" be include in the path to ensure that the application knows where everything is located that it may need? "

Applications do not look for "lib" and "include" in the PATH. Putting those libraries in the PATH serves no purpose.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 01-15-2004, 08:42 AM   #6
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
Originally posted by louisb
Thanks for your help I was not source the file properly. I was only using the following: "./filename" when i changed it to ". ./filename" it worked just fine. However, I do have another question. Shoudn't "lib" and "include" be include in the path to ensure that the application knows where everything is located that it may need?
The PATH variable should only include directories containing binaries. There are other variables to specify the "extra stuff" (as benjithegreat98 put it). For example, java uses CLASSPATH. If your binaries are properly built (and they usually are), they will know to look in lib for libraries.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
Apache path and kde path questions darkraider Debian 1 11-12-2005 05:07 AM
scripting path navigation toddcurry Programming 1 05-26-2005 10:09 PM
Removing path form PATH maginotjr Linux - Newbie 3 02-12-2005 02:23 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:51 AM.

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