Re: Exporting Environmental Variables

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 25 2014 - 12:59:05 MDT

Hi Carl,

I think the issue stems from the fact that the variables (even tcsh setenv
commands) are only valid while a given shell session is logged in. It seems
as if the system command starts a new shell (bash by default for me, even
though my default environments are tcsh) with each call to system and then
closes that shell, causing any variables set there to be lost with the
exiting of that new shell.

My workaround is generally to have scripts write things to a given file in
a given directory. You could perhaps create a system-wide directory to have
a bunch of files in it that simulate variables - the variable name would be
the file name within that folder, and the variable's value would be the
content of that text file. It's probably pretty simple to even make
functions for this that would read/write the variables (given variable name
and value(s)), test for existence, clear all, etc. Far from an ideal
solution, but one that will also allow any program (not just NCL) to access
and/or alter the 'variables'...

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2@wisc.edu

On Tue, Mar 25, 2014 at 9:53 AM, Carl Schreck <cjschrec@ncsu.edu> wrote:

> Is there a way for NCL to set an environmental variable, such that it
> could be accessed by bash after NCL exits?
>
> It seems like it has very short-term memory:
>
> ncl 8> system( "export TEMP=hello; echo $TEMP")
> hello
> ncl 9> system( "echo $TEMP")
> *[blank line]*
>
> Thanks!
>
> Carl
>
> --
>
> <http://www.cicsnc.org/>
> <http://www.facebook.com/cicsnc>
> *Carl J. Schreck III, PhD*
> *Research Associate*
> Cooperative Institute for Climate and Satellites NC <http://cicsnc.org/>
> North Carolina State University <http://ncsu.edu/>
> NOAA's National Climatic Data Center <http://ncdc.noaa.gov/>
> 151 Patton Ave, Asheville, NC 28801
> e: cjschrec@ncsu.edu
> o: +1 828 257 3140
> CycloneCenter.org: Help analyze tropical cyclones<http://cyclonecenter.org/>
> monitor.cicsnc.org/mjo: See recent MJO diagnostics<http://monitor.cicsnc.org/mjo/>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 25 12:59:48 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 31 2014 - 11:47:09 MDT