- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- exporting 'trap' to other shell
Operating System - HP-UX
1752569
Members
5547
Online
108788
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО07-23-2010 05:36 AM
тАО07-23-2010 05:36 AM
exporting 'trap' to other shell
Hi Gurus,
I want to know is there any way to export following line to new shell also.
trap 'date "+# %c" | read -s' debug
when i do sh and enter to new shell this trap stop working (there need to run again same)
Chandra
I want to know is there any way to export following line to new shell also.
trap 'date "+# %c" | read -s' debug
when i do sh and enter to new shell this trap stop working (there need to run again same)
Chandra
- Tags:
- trap
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2010 05:44 PM
тАО07-23-2010 05:44 PM
Re: exporting 'trap' to other shell
Hi Chandra:
You can export variables but not code. In this case, you could place the line in question into a file that you source (or "include") when spawning a new shell. Thus, any shell could do:
#!/usr/bin/sh
echo "I am born..."
. /usr/local/bin/myshtraps
...
Where '/usr/local/bin/myshtraps' contains the line of code you described. Note that shell's sourcing (reading or including) the material are called with a dot ('.') followed by whitespace and the file name. This adds the code and/or variables to the current environment for its use rather than spawning a new subshell.
Regards!
...JRF...
You can export variables but not code. In this case, you could place the line in question into a file that you source (or "include") when spawning a new shell. Thus, any shell could do:
#!/usr/bin/sh
echo "I am born..."
. /usr/local/bin/myshtraps
...
Where '/usr/local/bin/myshtraps' contains the line of code you described. Note that shell's sourcing (reading or including) the material are called with a dot ('.') followed by whitespace and the file name. This adds the code and/or variables to the current environment for its use rather than spawning a new subshell.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-23-2010 10:41 PM
тАО07-23-2010 10:41 PM
Re: exporting 'trap' to other shell
hi Chandra,
If it is a single line of command, then you can assing the command to a variable and export the variable.
For E.g.
#cat test.sh
#!/usr/bin/sh
echo "hello"
export MYCMD="echo Today is `date '+%d %m %y'`"
/tmp/child.sh
# cat child.sh
#!/usr/bin/sh
echo "`$MYCMD`"
HTH
Muru
If it is a single line of command, then you can assing the command to a variable and export the variable.
For E.g.
#cat test.sh
#!/usr/bin/sh
echo "hello"
export MYCMD="echo Today is `date '+%d %m %y'`"
/tmp/child.sh
# cat child.sh
#!/usr/bin/sh
echo "`$MYCMD`"
HTH
Muru
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP