- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to return variable to parent shell?
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
04-21-2005 05:13 PM
04-21-2005 05:13 PM
My problem is the following
For example I do
#sh
#a=1
#echo $a
1
#exit
#echo $a
#
How to get value of variable "a" in my parent shell?
thanx
Solved! Go to Solution.
- Tags:
- exit status
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2005 05:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2005 05:21 PM
04-21-2005 05:21 PM
Re: How to return variable to parent shell?
it doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2005 05:22 PM
04-21-2005 05:22 PM
Re: How to return variable to parent shell?
parent shell, so "echo $?" in parent shell after
execution would give the value of a (i.e 1 in your
example).
I'm not sure if that what you asked. If you want to
set the variable a in the parent shell, then that can't
be done. You can't set a parameter to some value
automatically in the parent shell. You can only set a
variable to a value in a child shell by using "export a".
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2005 05:26 PM
04-21-2005 05:26 PM
Re: How to return variable to parent shell?
everything works
thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2005 05:26 PM
04-21-2005 05:26 PM
Re: How to return variable to parent shell?
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=14148
- Biswajit
- Tags:
- broken URL link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2005 02:05 AM
04-24-2005 02:05 AM
Re: How to return variable to parent shell?
For simple cases and depending on what you're doing, you don't need a file. Simply use Command Substitution.
In the following, in the local shell, we're setting xx to the standard output of the execution of a child shell. The child shell does some testing and then echoes (to standard out) various values depending on the results of his tests. The parent shell (our shell) can then check the value of xx:
Pine3 ## touch /tmp/foo ;\
xx=$(
if [ -f /tmp/foo ]
then echo 'foo_exists'
else echo 'foo_gone'
fi
);\
if [ "$xx" = 'foo_exists' ]
then echo "\n**it's all good!**"
else echo "\n**crap! where's foo?**"
fi
**it's all good!**
Pine3 ## rm /tmp/foo ;\
xx=$(
if [ -f /tmp/foo ]
then echo 'foo_exists'
else echo 'foo_gone'
fi
);\
if [ "$xx" = 'foo_exists' ]
then echo "\n**it's all good!**"
else echo "\n**crap! where's foo?**"
fi
**where's foo?**
HTH
bv