Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 8th, 2006, 5:48 AM   #1
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
Path=$path:

I redirected env into a file, and then altered it a little so that I could set the environmental variables when a script is executed.

I was having a problem when the script was being executed by cron.

In the end it worked out ok but I was wondering if anyone could explain each part of the command I added or has a link to a page that had some info on it. I found the command in a scripting book and then again on the web but neither of them went into any detail.

I hate using code that I don’t understand.

PATH=$PATH:/usr/local/bin
export PATH

This is what I think is happening:
The PATH=/usr/local/bin sets the variable to what ever is on the right hand side of the =

Export PATH exports the variable, as it is a global variable it is able to do this (can some one confirm this is correct)

$PATH: was on a line that followed PATH=/usr/local/bin so I assume this somhow appends the string within the variable (this is a guess and the part I am most confused by). What is the “:” all about?.

hush
hush is offline   Reply With Quote
Old Jul 9th, 2006, 2:12 AM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,466
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Quote:
This is what I think is happening:
The PATH=/usr/local/bin sets the variable to what ever is on the right hand side of the =
Yes, you are correct.

Quote:
Export PATH exports the variable, as it is a global variable it is able to do this (can some one confirm this is correct)
Exporting the variable, makes the value of the variable accessible by the system... as in a "system environment variable".

Quote:
$PATH: was on a line that followed PATH=/usr/local/bin so I assume this somhow appends the string within the variable (this is a guess and the part I am most confused by). What is the “:” all about?.
$PATH is used as a place holder for the value of the current path. The new path (/usr/local/bin) is appended to the current path ($PATH). The : is a delimeter to separate the various directories specified in the path.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 9th, 2006, 7:25 AM   #3
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
Cheers IR.
hush is offline   Reply With Quote
Old Jul 10th, 2006, 10:31 AM   #4
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Quote:
Exporting the variable, makes the value of the variable accessible by the system... as in a "system environment variable".
Maybe you mean system in a different way, but export assures that the current process and all children of the process can see this version (in this case PATH) of a variable. It doesn't cross parent/child process lines, ie., my neighbor's processes can't see it.
jim mcnamara is offline   Reply With Quote
Old Jul 10th, 2006, 12:55 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,466
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Hence the quotes... I was trying to be abstract to provide simplicity.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC