• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

PATH in SOLARIS 2.5.1

How can I define PATH for installed programs in SOLARIS 2.5.1?
0
magdy
Asked:
magdy
  • 2
1 Solution
 
terrycjCommented:
This is not a very specific question.

Programs you execute under Solaris will inherit the PATH that
is in the environment of the process that executes them.

So if you, as a user, want a program you execute to have a
certain directory in its PATH, you can simply add it to your
own PATH. This is the simplest solution, but other people
will not benefit from your change.

If you want to arrange that a certain executable always have a certain directory in its PATH, I'd write a 3 line shell script to
add the directory and execute the program. Here's an example - suppose you want /usr/local/etc/httpd/httpd to be executed with the directory /usr/local/bin in its PATH. Create a file called
run-httpd and put it somewhere (in YOUR path). In it, put the following

#!/bin/sh
PATH=/usr/local/bin:$PATH
exec /usr/local/etc/httpd/httpd "$@"


then use this run-httpd script to invoke httpd. You'll probably
want to make this script executable via

chmod +x run-httpd

terry.

0
 
magdyAuthor Commented:
That's good.
But how can I define PATH as you said
"Create a file called run-httpd and put it somewhere (in YOUR path)"

I mean, I put it in .profile or what ? and what is the syntax for it?
Thanks

0
 
terrycjCommented:
The easiest is to log in and type this:

echo $PATH

that will show you the list (separated with colons) of
directories in your path. Choose one of these to put the
script I wrote above into. A typical choice would be
/usr/local/bin

If /usr/local/bin is not in your path (as revealed by echo $PATH)
you can put it there by editing your .profile (if the shell
you are using is an sh-like shell). You'd do something like
this:

PATH=/usr/local/bin:$PATH

to prepend /usr/local/bin to the existing value of your path.
In csh-like shells, you should change your .cshrc to include
a line like

setenv PATH /usr/local/bin:$PATH

Then you stick the script into /usr/local/bin and run the
above chmod command.

Of course, /usr/local/bin may not be the best place, and
you may not have root access anyway. Many people have a
directory called bin in which they put their scripts. You
may already have one, and it may already be in your path.
If not,

PATH=$HOME/bin:$PATH

in your .profile, as above etc.


I hope this helps more.

Terry.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now