- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- $PATH Question.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 06:44 AM
11-15-2002 06:44 AM
Here is the scenario
wePATH=$APPPATH/usr/bin:;export PATH have on machine A
PATH=$APPPATH/usr/bin;export PATH
On machine B (note the missing :)
what is the difference and impact of not having this
Thanks
David.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 06:43 AM
11-15-2002 06:43 AM
Re: $PATH Question.
In your case none, if you add an other path you have to use : as a seperator.
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 06:44 AM
11-15-2002 06:44 AM
Re: $PATH Question.
The ":" is a delimiter character for parsing the component fields. Its absence (or presence) at the end of the string doesn't matter.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 06:50 AM
11-15-2002 06:50 AM
Re: $PATH Question.
In the first example, the : is not needed because you don't have another path to enter. The : is nothing more than a separator.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 06:51 AM
11-15-2002 06:51 AM
Re: $PATH Question.
$APPPATH and /usr/bin
ie:
$APPPATH:/usr/bin
!
The : is not required at the end.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 07:33 AM
11-15-2002 07:33 AM
SolutionGood question. I played with it a bit, and it looks like the colon on the end does make a difference (at least with the regular PATH environment variable, not sure if your APPPATH works the same way). See, the colon is the field separator for the PATH variable. With a colon at the end, you are specifying a null field, which PATH interprets to be the current directory.
To test it, I created a script (mytest) with executable permissions in my home directory. I set my path to the default:
export PATH=/usr/bin
and tried to find my script:
# type myscript
myscript not found.
(Yes, I did it as root, but it is on a brand new test box!) Now, set the PATH with the colon on the end:
# export PATH=/usr/bin:
# type myscript
myscript is /root_home/myscript
So it makes a difference with the PATH variable. If your APPPATH behaves just like the PATH does, the difference is that the machine with the colon on the end of APPPATH will include the current directory, while the other APPPATH won't.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 08:03 AM
11-15-2002 08:03 AM
Re: $PATH Question.
Note that the current directory is specified by a null path name, which can appear immediately after the equal sign, between colon delimiters, or at the end of the path list.
I always thought a "." in PATH specified the current directory.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 08:09 AM
11-15-2002 08:09 AM
Re: $PATH Question.
Now I've gotta go check all the PATH settings for root on all my boxes. ;)
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 09:05 AM
11-15-2002 09:05 AM
Re: $PATH Question.
Ditto for me, too! Nasty. After your post, John, I tried the same test and got the same results as you. I looked up the man pages for 'sh-posix' and as Darrell quoted...well, I too, thought that dot (.) was the only problem.
Fortunately my boxes contain properly formatted PATH variables!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 11:17 AM
11-15-2002 11:17 AM
Re: $PATH Question.
It gets even better. I checked the PATH setting for root on all my boxes for the colon at the end of the path or in the middle of the path. I was pretty sure I was ok. Wrong! I found two boxes where the PATH had a double colon in the middle of the PATH setting. Here is a portion of the .profile for root on both boxes:
PATH=/usr/sbin:$PATH:$OV_BIN:/sbin:/root_home/bin
The $OV_BIN environment variable was never set when .profile was executed, so the PATH wound up with :: in the middle. I tested it by doing a 'type somescript' where 'somescript' was an executable script in root's home directory, and sure enough it found it.
I took the HP-UX Operating System Security class a couple of years ago. I dug out my class notes just to see if we covered the issue. There was a slide warning about putting '.' in your path and how it opens up the danger for trojan scripts, but nothing about the colon issue. Maybe they can add this to it some day.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2002 11:46 AM
11-15-2002 11:46 AM
Re: $PATH Question.
- $PWD not in $PATH
- *NO* $PATH directory should ever be world writable
- ideally, no directory should be group writable either
- no PATH entry should be a symlink
and for good measure:
- no duplicates in the PATH (HP-UX will search again and again...)
- remove non-existant directories in $PATH
- check that a PATH entry is really a directory and not a file
All of this is checked in the attached script for both /etc/PATH as well as the current user's $PATH
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2002 08:38 AM
11-18-2002 08:38 AM
Re: $PATH Question.
Thanks
David.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2002 09:11 AM
11-18-2002 09:11 AM
Re: $PATH Question.
> setenv PATH `perl -e '($P=$ENV{PATH})=~s://+:/:g;$P=~s/::+/:/g;$P=~s,(:/usr/bin/X11)(?=:),$1R6$1,;foreach(split m/:+/,$P){-d&&$P{$_}++==0&&push@P,$_;}print join":",@P;'`
It strips non-existing or duplicate folders.
For even more security, you can do something like
> setenv PATH `perl -MCwd=abs_path -e '($P=$ENV{PATH})=~s://+:/:g;$P=~s/::+/:/g;$P=~s,(:/usr/bin/X11)(?=:),$1R6$1,;foreach(split m/:+/,$P){-d&&$P{abs_path$_}++==0&&push@P,abs_path$_;}print join":",@P;'`
Easy to change to strip '.' too:
> setenv PATH `perl -MCwd=abs_path -e '($P=$ENV{PATH})=~s://+:/:g;$P=~s/::+/:/g;$P=~s,(:/usr/bin/X11)(?=:),$1R6$1,;foreach(split m/:+/,$P){m:^[/.]+$/&&next;-d&&$P{abs_path$_}++==0&&push@P,abs_path$_;}print join":",@P;'`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2002 09:28 AM
11-18-2002 09:28 AM
Re: $PATH Question.
export PATH=/usr/bin:./:../.:./././.:.:
it will not detect ./ (trailing slash)
my final perl snippet does:
m/^[./]+$/&&next;
will skipp all path elements consisting of dots and slahes only