Export in bash
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Export in bash




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Export in bash  
lak


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-18-07 06:25 PM

if i export a variable it exports to its child only.
how can i export variables from child shell to parent?






[ Post a follow-up to this message ]



    Re: Export in bash  
Robert Harris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-18-07 06:25 PM

lak wrote:
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?
>
You can't.

Robert





[ Post a follow-up to this message ]



    Re: Export in bash  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-18-07 06:25 PM

On 2007-10-18, lak wrote:
>
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?

You can't.

However, you can have a script print a value and assign that to a
variable in the parent:

val=$( your_script )

If you need to set more than one variable, have the script (or a
command that allows formatting of its output) print assignment
statements and use eval:

eval "$( date +"year=%Y month=%m day=%d" )"


--
Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
Shell Scripting Recipes:     |  My code in this post, if any,
A Problem-Solution Approach  |         is released under the
2005, Apress                 |    GNU General Public Licence





[ Post a follow-up to this message ]



    Re: Export in bash  
fred.l.kleinschmidt@boeing.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-20-07 12:20 AM

On Oct 18, 7:20 am, lak <lakindi...@gmail.com> wrote:
> if i export a variable it exports to its child only.
> how can i export variables from child shell to parent?

"Source" the child shell. That is, instead of executing it with:
myshell
run it in the local shell by prepending a period and space:
. myshell

--
Fred Kleinschmidt






[ Post a follow-up to this message ]



    Re: Export in bash  
Scott Lurndal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-23-07 12:22 AM

fred.l.kleinschmidt@boeing.com writes:
>On Oct 18, 7:20 am, lak <lakindi...@gmail.com> wrote: 
>
>"Source" the child shell. That is, instead of executing it with:
>    myshell
>run it in the local shell by prepending a period and space:
>   . myshell
>


potentially dangerous.  exit, for example, has significantly
different effect if it is sourced vs. execed.

scott





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:59 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register