- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: set Path in script not working
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
10-18-2000 05:40 PM
10-18-2000 05:40 PM
I have a simple yet fustrating problem in executing a set PATH command in my script.
e.g.
PATH=/home:$PATH
export PATH
echo $PATH
the echo $PATH is for the purpose of debugging.
When I run the script, the echo statement reflect that /home is added to the PATH.
But once, the script is finished executing when I did an echo $PATH at the commandline, the /home isn't in the PATH.
Can anyone kindly help?
Thanks a million.
Han Ming
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2000 06:01 PM
10-18-2000 06:01 PM
Re: set Path in script not working
Add /sbin/sh to end of script then type echo $PATH, type exit to close the shell and finish script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2000 06:20 PM
10-18-2000 06:20 PM
Re: set Path in script not working
Your script executes in its own environment. While this environment includes your shell's variables it is destroyed upon exit. The PATH variable is treated as a local variable (i.e. not global) when referenced by your script. Stated differently, your script gets a copy of the global variable. The behavior you describe is expected.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2000 06:29 PM
10-18-2000 06:29 PM
Re: set Path in script not working
In this case, how do I set the global variable.
Thanks again for the advice.
Han Ming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2000 07:05 PM
10-18-2000 07:05 PM
SolutionIf you want the variable setting be valid in you current shell, you need to put a dot before the script name . e.g.
#. script.sh
the dot tells the shell to source the environment variable setting inside the script to be the global variable of the current shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2000 07:40 PM
10-18-2000 07:40 PM
Re: set Path in script not working
Thanks for all the help.
I guess it has solved my problem totally.
Thanks very much once again.
Han Ming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2000 12:27 PM
10-20-2000 12:27 PM