|
Home > Archive > Unix Shell > February 2007 > Help: Add variable to $PATH
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help: Add variable to $PATH
|
|
| Amy Lee 2007-02-22, 1:24 am |
| Hi,
I build a shell script to install a software. The last section is to add
some variables to the user's $PATH.
Before add variables, the $PATH in .bash_profile is
PATH=$PATH:$HOME/bin
After add variables, it looks like
PATH=/opt/dic/bin:$PATH:$HOME/bin
or
PATH=$PATH:$HOME/bin:/opt/dic/bin
Thanks in advance.
Regards,
Amy Lee
| |
| Chris F.A. Johnson 2007-02-22, 7:19 am |
| On 2007-02-22, Amy Lee wrote:
> Hi,
>
> I build a shell script to install a software. The last section is to add
> some variables to the user's $PATH.
>
> Before add variables, the $PATH in .bash_profile is
> PATH=$PATH:$HOME/bin
> After add variables, it looks like
> PATH=/opt/dic/bin:$PATH:$HOME/bin
> or
> PATH=$PATH:$HOME/bin:/opt/dic/bin
I don't understand the problem.
Just put the command you want into your .bash_profile.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| Amy Lee 2007-02-22, 7:19 am |
| On Thu, 22 Feb 2007 03:44:59 -0500, Chris F.A. Johnson wrote:
> On 2007-02-22, Amy Lee wrote:
>
> I don't understand the problem.
>
> Just put the command you want into your .bash_profile.
Hmm, sorry.
I mean that I hope my script can add the variable in the $PATH directly.
Thanks.
| |
| Ed Morton 2007-02-22, 7:19 am |
| Amy Lee wrote:
> On Thu, 22 Feb 2007 03:44:59 -0500, Chris F.A. Johnson wrote:
>
>
>
>
> Hmm, sorry.
> I mean that I hope my script can add the variable in the $PATH directly.
> Thanks.
I'm not sure if this is what you mean, but if you want your script to
modify an environment variable such as PATH, the user needs to execute
it as ". script" instead of just "script".
Ed.
| |
| Michael Tosch 2007-02-22, 1:18 pm |
| Amy Lee wrote:
> Hi,
>
> I build a shell script to install a software. The last section is to add
> some variables to the user's $PATH.
>
I think you want '$VAR' to be written (single ticks),
so .bash_profile contains $VAR string (to be expanded at the time
..bash_profile is run).
But that is still the a questionable concept.
Better add a common directory *once* into each user's .bash_profile
where you have write access, say /opt/bin.
Then put wrapper scripts in /opt/bin for each software.
E.g. /opt/bin/acroread
#!/bin/sh
prog=`basename $0`
dir=/opt/acroread/5.0.10/bin
PATH=${dir}:$PATH
export PATH
[ -x $dir/$prog ] && exec $prog "$@"
If the software has many executables, say
there is /opt/acroread/5.0.10/bin/acrowrite
then simply add a symlink
/opt/bin/acrowrite -> acroread
If you are using many software versions,
I recommend to use "modules".
Maybe it is installed on your systems already?
Try
man module
--
Michael Tosch @ hp : com
|
|
|
|
|