[Fwd: Re: Changing Directory Within NCL Script]

From: Andrew Mai <mai_at_nyahnyahspammersnyahnyah>
Date: Fri, 03 Jul 2009 05:12:57 -0600

Lunde, Bruce N CIV NAVOCEANO, NP1 wrote:

> I had wanted to change the current working
> directory within my NCL script. I had
> tried doing system("cd NewDir"), which
> did not work.

While it is generally true in the Unix world that a child process
(sub-shell) cannot modify the environment of the parent process (shell),
there is a way to run commands in a script *in the context of the
current shell*. In csh, this is called "source". In Korn shell the
syntax is to prepend a dot (e.g., ". ./script"). No such mechanism
exists in NCL. This is an advanced topic and not something that is
likely to be incorporated into NCL any time soon, I think.

On the other hand, MATLAB and IDL have a CD function which does exactly
what you want to do (change the current working directory). I wonder how
difficult it would be to incorporate such a function into NCL. It would
be quite useful.

Andy

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 03 2009 - 05:12:57 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 07 2009 - 11:13:18 MDT