- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Setting my SHELL variables
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
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
08-26-2004 05:46 AM
08-26-2004 05:46 AM
Setting my SHELL variables
I have shell script(run.sh) where i set my variables like
--------------------------
PATH=/opt/bea/hom
CLASSPATH=/opt/bea/weblogic.jar
export PATH
export CLASSPATH
---------------------------
I do the following
1.sh run.sh
2.echo $CLASSPATH
FOr some reasons, the one set in my shell script is not being reflected in my shell, Can you help know where i am doing it wrong.
Tks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 05:51 AM
08-26-2004 05:51 AM
Re: Setting my SHELL variables
You need to source the file, not run it - EX:
. run.sh
That way it applies to your current shell. When you run it it only applies to the shell that runs it...and then exits.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 05:52 AM
08-26-2004 05:52 AM
Re: Setting my SHELL variables
./run.sh
Without the sh.
HTH,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 05:53 AM
08-26-2004 05:53 AM
Re: Setting my SHELL variables
The variables are being set in a child shell when you run # sh run.sh
Those variables, even if exported, are not passed back to the parent shell that ran the program.
Instead you could do: ./run.sh
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 05:57 AM
08-26-2004 05:57 AM
Re: Setting my SHELL variables
1) ./run.sh and
2) echo $PATH
But the path is not being reflected :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:00 AM
08-26-2004 06:00 AM
Re: Setting my SHELL variables
export PATH=/opt/bea/hom
And then do:
echo $PATH
It should reflect your PATH.
If you try to source the file like Jeff suggest, will that work?
HTH,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:01 AM
08-26-2004 06:01 AM
Re: Setting my SHELL variables
Just tested it:
. run.sh
/no points please/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:08 AM
08-26-2004 06:08 AM
Re: Setting my SHELL variables
Rename the file from run.sh to .run.sh
chmod 666 .run.sh
$. ./.run.sh
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:17 AM
08-26-2004 06:17 AM
Re: Setting my SHELL variables
You just need to do:
. run.sh
Note that there is a SPACE between the first . and the run.sh. That is what tells the shell to apply the settings to your running shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:23 AM
08-26-2004 06:23 AM
Re: Setting my SHELL variables
When i do a
$ . run.sh
i get the following,
$ su: run.sh not found.
any idea where i could be wrong. I have the permissions..
Tks, Nag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:26 AM
08-26-2004 06:26 AM
Re: Setting my SHELL variables
. ./run.sh
Your local-path is not your PATH variable so use ./ infront of it.
HTH,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:26 AM
08-26-2004 06:26 AM
Re: Setting my SHELL variables
That's because your current dir is not in the path - do it this way
. ./run.sh
./ tells it to look in your current dir.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 06:59 AM
08-26-2004 06:59 AM
Re: Setting my SHELL variables
Sourcing can be included in a script and in your example for WebLogic, you can source the run.sh as mentioned above with just . shell-script. This is a common way to provide shell variab;les to every user login too. Just source a script in /etc/profile and now everyone gets the env values.
You might want to update your script to take advantage of POSIX shell features such as type and assign on one line:
export PATH=/opt/bea/hom
export CLASSPATH=/opt/bea/weblogic.jar
Also, all your shell scripts should explicitly define the shell interpreter on line 1. Just insert this as line 1:
#!/usr/bin/sh
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2004 12:59 PM
08-26-2004 12:59 PM