- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script--Need Help
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
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
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
01-24-2012 07:18 AM
01-24-2012 07:18 AM
shell script--Need Help
./ seems do magic in many occasions. What is behind this?
./test.ksh works, but test.ksh give test.ksh not found.
Thanks.
- Tags:
- PATH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2012 07:27 AM - last edited on 06-29-2021 12:10 AM by Ramya_Heera
01-24-2012 07:27 AM - last edited on 06-29-2021 12:10 AM by Ramya_Heera
Re: shell script--Need Help
This is down to the PATH environment variable - i.e. the directories that the shell will look in to run a command. You can see what it is currently set to using:
echo $PATH
So anything in those directories will be searched to run the command you type.
I'm assuming you are attempting the command you specify as root? For root it is not a good idea to have the current directory on the PATH as it makes it easy for folks to inject trojans into the system by leaving scripts that attack a system in directories with names similar to standard commands. Of course when you are root you get round this by explicitly referencing the current directory by adding ./ to the start of the command.
If you look at standard .profiles for non-root users you will see that often the current directory is added to the PATH as follows:
PATH=$PATH:.
But it is NOT a good idea to make this change for root.
I am an HPE Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2012 01:55 PM
01-24-2012 01:55 PM
Re: shell script-- $PATH lookup
>./ seems do magic in many occasions. What is behind this?
This is elementary shells 101.
As Duncan said, for all commands that are not relative, absolute or builtin, it looks them up in $PATH.
Adding "./" makes the command have a relative path.