- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: export in a script
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
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
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-20-2000 01:42 AM
тАО10-20-2000 01:42 AM
export in a script
When i export a variable in a script, and try to use it from command prompt it does not seem to work.
ex:- in file a.sh
export PRA=XXX
echo $PRA
execute a.sh
then try to do echo from prompt, the value is not set.
What should I do set the value.
please help
Praveen
- Tags:
- environment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2000 01:47 AM
тАО10-20-2000 01:47 AM
Re: export in a script
The is expected. The variable is local to your script (environment). Only children of your script or inherit the variable.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2000 01:49 AM
тАО10-20-2000 01:49 AM
Re: export in a script
this is normal behaviour.
export in a script is not 'back' exported.
When you start a script it executes in a sub shell that terminates on ending the script.
To have the variables in your own shell 'dot' the script:
. a.sh
then your script will not run in a subshell.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2000 01:50 AM
тАО10-20-2000 01:50 AM
Re: export in a script
if you want shotcuts for some commands you better use the alias function. ie:
alias cdhome="cd /home"
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2000 01:53 AM
тАО10-20-2000 01:53 AM
Re: export in a script
In addition to sourcing another file, you can create and export variables you need in your $HOME/.profile. This is often done with for Oracle user profiles.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2000 01:18 PM
тАО11-16-2000 01:18 PM
Re: export in a script
echo "Value" > valueFile
and then set the value from the command prompt by using command substitution,
var=$( cat valueFile )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2000 02:48 PM
тАО11-16-2000 02:48 PM
Re: export in a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2000 05:26 PM
тАО11-16-2000 05:26 PM
Re: export in a script
. ab.sh
This will treat the file like .profile and then you will retain the variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2000 05:28 PM
тАО11-16-2000 05:28 PM
Re: export in a script
. ab.sh
NOTE THE DOT
THis will treat the script as a .profile. THe variables should then take properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 02:33 AM
тАО11-17-2000 02:33 AM
Re: export in a script
I don't think the execute bit even needs to be set when a file is sourced. The PATH variable will be referenced, however, if a path is not specified on the command line.