Solved

PATH in SOLARIS 2.5.1

Posted on 1997-12-16
3
362 Views
Last Modified: 2013-12-27
How can I define PATH for installed programs in SOLARIS 2.5.1?
0
Comment
Question by:magdy
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
terrycj earned 50 total points
ID: 2008377
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
 

Author Comment

by:magdy
ID: 2008378
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
 
LVL 1

Expert Comment

by:terrycj
ID: 2008379
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now