- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- export variables to outside of 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
тАО06-21-2006 06:49 AM
тАО06-21-2006 06:49 AM
#!/bin/ksh
export fruit=orange
but, after running the script, other scripts still can not see it :-(
how do I make it happen?
thank you
Solved! Go to Solution.
- Tags:
- export
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 06:54 AM
тАО06-21-2006 06:54 AM
Re: export variables to outside of a script
Source (read) the script with the variable(s) you need. For example:
# cat /tmp/A
#!/usr/bin/sh
fruit=apple
# cat /tmp/B
#!/usr/bin/sh
fruit=apple
# /tmp/B
I want a(n) apple
...Note the dot, followed by a space, followed by the script to be sourced (read).
Regards!
...JRF...
- Tags:
- source
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:00 AM
тАО06-21-2006 07:00 AM
Re: export variables to outside of a script
you defined apple both in /tmp/A and /tmp/B......
am I missing something..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:06 AM
тАО06-21-2006 07:06 AM
Re: export variables to outside of a script
so easy, but I made it too complicated!!
thank you!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:23 AM
тАО06-21-2006 07:23 AM
Re: export variables to outside of a script
when you export a variable it's only be used by current and it's child shells. if you export it within a script, it doesn't pass to parent shell. so you can't get the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:55 AM
тАО06-21-2006 07:55 AM
Re: export variables to outside of a script
>when you export a variable it's only be used by current and its child shells.
Right. The only way to see it is to either source it as JRF said, or to return a string with the info. Similar to:
eval $(resize)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 12:07 PM
тАО06-21-2006 12:07 PM
Re: export variables to outside of a script
what do you meant by "eval $(resize)"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 12:44 PM
тАО06-21-2006 12:44 PM
Re: export variables to outside of a script
Basically resize (for X windows) wants to change the LINES and COLUMNS variables. Since it can't export those values (it's an executable), it outputs to stdout:
$ resize
COLUMNS=80;
LINES=36;
export COLUMNS LINES;
And then eval does the export, kind of like sourcing it, in the current shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 12:47 PM
тАО06-21-2006 12:47 PM
Re: export variables to outside of a script
go back to square 1....