* Accessing Shell Variables
@ 2016-12-28 18:19 ahlan.marriott
2016-12-28 19:47 ` Victor Porton
2016-12-28 19:50 ` Niklas Holsti
0 siblings, 2 replies; 6+ messages in thread
From: ahlan.marriott @ 2016-12-28 18:19 UTC (permalink / raw)
Hi,
I can access Windows, Linux and Osx environment variables using Ada.Environment_Variables.Value
However Linux and Osx also have Shell variables.
How can I access these?
Ahlan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing Shell Variables
2016-12-28 18:19 Accessing Shell Variables ahlan.marriott
@ 2016-12-28 19:47 ` Victor Porton
2016-12-28 20:51 ` Simon Wright
2016-12-28 19:50 ` Niklas Holsti
1 sibling, 1 reply; 6+ messages in thread
From: Victor Porton @ 2016-12-28 19:47 UTC (permalink / raw)
ahlan.marriott@gmail.com wrote:
> I can access Windows, Linux and Osx environment variables using
> Ada.Environment_Variables.Value However Linux and Osx also have Shell
> variables. How can I access these?
You cannot access a shell variable unless it is exported. Exported shell
variable becomes and environment variable:
xxx=yyy
./my-program # my-program cannot (at least in an easy way) access $xxx
export xxx=yyy
# or
xxx=yyy
export xxx
./my-program # my-program cannot access xxx environment variable
--
Victor Porton - http://portonvictor.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing Shell Variables
2016-12-28 18:19 Accessing Shell Variables ahlan.marriott
2016-12-28 19:47 ` Victor Porton
@ 2016-12-28 19:50 ` Niklas Holsti
1 sibling, 0 replies; 6+ messages in thread
From: Niklas Holsti @ 2016-12-28 19:50 UTC (permalink / raw)
On 16-12-28 20:19 , ahlan.marriott@gmail.com wrote:
> Hi,
>
> I can access Windows, Linux and Osx environment variables using Ada.Environment_Variables.Value
> However Linux and Osx also have Shell variables.
> How can I access these?
I think that's not possible, in any programming language. I have never
heard of an OS service (API) that would access shell variables.
(BTW, I think some Windows shells also have shell variables.)
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing Shell Variables
2016-12-28 19:47 ` Victor Porton
@ 2016-12-28 20:51 ` Simon Wright
2016-12-28 21:38 ` Victor Porton
0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2016-12-28 20:51 UTC (permalink / raw)
Victor Porton <porton@narod.ru> writes:
> ahlan.marriott@gmail.com wrote:
>
>> I can access Windows, Linux and Osx environment variables using
>> Ada.Environment_Variables.Value However Linux and Osx also have Shell
>> variables. How can I access these?
>
> You cannot access a shell variable unless it is exported. Exported shell
> variable becomes and environment variable:
>
> xxx=yyy
> ./my-program # my-program cannot (at least in an easy way) access $xxx
>
> export xxx=yyy
> # or
> xxx=yyy
> export xxx
> ./my-program # my-program cannot access xxx environment variable
This variant is the one that *can* access the environment variable.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing Shell Variables
2016-12-28 20:51 ` Simon Wright
@ 2016-12-28 21:38 ` Victor Porton
2016-12-29 9:42 ` ahlan.marriott
0 siblings, 1 reply; 6+ messages in thread
From: Victor Porton @ 2016-12-28 21:38 UTC (permalink / raw)
Simon Wright wrote:
> Victor Porton <porton@narod.ru> writes:
>
>> ahlan.marriott@gmail.com wrote:
>>
>>> I can access Windows, Linux and Osx environment variables using
>>> Ada.Environment_Variables.Value However Linux and Osx also have Shell
>>> variables. How can I access these?
>>
>> You cannot access a shell variable unless it is exported. Exported shell
>> variable becomes and environment variable:
>>
>> xxx=yyy
>> ./my-program # my-program cannot (at least in an easy way) access $xxx
>>
>> export xxx=yyy
>> # or
>> xxx=yyy
>> export xxx
>> ./my-program # my-program cannot access xxx environment variable
>
> This variant is the one that *can* access the environment variable.
Yes, my typo.
--
Victor Porton - http://portonvictor.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing Shell Variables
2016-12-28 21:38 ` Victor Porton
@ 2016-12-29 9:42 ` ahlan.marriott
0 siblings, 0 replies; 6+ messages in thread
From: ahlan.marriott @ 2016-12-29 9:42 UTC (permalink / raw)
On Wednesday, 28 December 2016 22:38:42 UTC+1, Victor Porton wrote:
> Simon Wright wrote:
>
> > Victor Porton <porton@narod.ru> writes:
> >
> >> ahlan.marriott@gmail.com wrote:
> >>
> >>> I can access Windows, Linux and Osx environment variables using
> >>> Ada.Environment_Variables.Value However Linux and Osx also have Shell
> >>> variables. How can I access these?
> >>
> >> You cannot access a shell variable unless it is exported. Exported shell
> >> variable becomes and environment variable:
> >>
> >> xxx=yyy
> >> ./my-program # my-program cannot (at least in an easy way) access $xxx
> >>
> >> export xxx=yyy
> >> # or
> >> xxx=yyy
> >> export xxx
> >> ./my-program # my-program cannot access xxx environment variable
> >
> > This variant is the one that *can* access the environment variable.
>
> Yes, my typo.
>
> --
> Victor Porton - http://portonvictor.org
Dear Victor,
Thank you for your reply.
I now understand (better) the difference between exported and non-exported shell variables.
Exporting the shell variable I wanted to access solves the problem.
Many thanks for answering my question ;-)
Best wishes,
Ahlan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-12-29 9:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 18:19 Accessing Shell Variables ahlan.marriott
2016-12-28 19:47 ` Victor Porton
2016-12-28 20:51 ` Simon Wright
2016-12-28 21:38 ` Victor Porton
2016-12-29 9:42 ` ahlan.marriott
2016-12-28 19:50 ` Niklas Holsti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox