[NTLUG:Discuss] OT - include bash script
Ben Weatherall
BWeatherall at pdxinc.com
Tue Jan 5 18:10:46 CST 2010
Have you tried "sourcing" the child script? Try:
message="hello world"
. $HOME/child.inc
It has been a while, so I don't remember if a #!/... line at the top of the child will cause problems or not.
_________________________________________________
BEN WEATHERALL | 817.367.4569
Configuration Manager
PDX-NHIN-Rx.com
-----Original Message-----
From: discuss-bounces at ntlug.org [mailto:discuss-bounces at ntlug.org] On Behalf Of Greg Edwards
Sent: Tuesday, January 05, 2010 3:22 PM
To: NTLUG Discussion List
Subject: [NTLUG:Discuss] OT - include bash script
Is it possible to have a bash script include code from another file and
maintain vars set by the parent script?
example:
parent script:
message="hello world"
$include child.inc
child.inc:
echo The message of the day is $message
The $include directive pulls the code fine, but vars set by the parent
are lost. In the above example $message is empty.
--
Greg E
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list