export variables to launched process?

Peter TB Brett peter.brett at livecode.com
Thu Feb 4 04:57:41 EST 2016


On 04/02/2016 08:36, Mark Waddingham wrote:
> On 2016-02-04 02:57, Richard Gaskin wrote:
>> I've successfully exported variables to a process run with shell, e.g.:
>>
>>     put shell("export somevar='Hello!'; ./test.sh")
>>
>> ...where test.sh simply echoes somevar to verify that it got it.
>>
>> Now I have a process I need to read and write to, but I don't know how
>> to export variables to it - clues?
>
> A process that gets launched either via shell or open process will
> inherit the environment variables set by the engine... So I think doing:
>
> put "Hello!" into $somevar
>
> put shell("./test.sh")
>    or
> open process ... for ...
>
> Should both have the effect that the launched process will see 'somevar'
> as specified.

Of course, it's a good idea to be able to construct a specific 
environment for a subprocess, so please go ahead and file a bug report 
asking us to extend "open process" to allow passing in an array of 
environment variables!

                                   Peter

-- 
Dr Peter Brett <peter.brett at livecode.com>
LiveCode Open Source Team

LiveCode on reddit: https://reddit.com/r/livecode




More information about the use-livecode mailing list