comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL and UNIX setenv
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL and UNIX setenv [message #25428] Sun, 17 June 2001 22:46 Go to next message
Daniel Peduzzi is currently offline  Daniel Peduzzi
Messages: 29
Registered: June 1999
Junior Member
I have an executable (compiled from C) which I'd like to
run from within IDL using SPAWN. However, I'd like to refer
to the executable without prepending a pathname:

IDL> spawn, "myprog", result

instead of

IDL>spawn,"/usr1/guest/bin/myprog", result

I tried to append the "/usr1/guest/bin/" directory to my UNIX
path before starting an IDL session, but the path information
doesn't seem to be propagated into IDL.

What else, if anything, can I do to get IDL to find "myprog"?


Dan
Re: IDL and UNIX setenv [message #25510 is a reply to message #25428] Tue, 19 June 2001 01:41 Go to previous message
nmw is currently offline  nmw
Messages: 18
Registered: January 1995
Junior Member
In article <Pine.LNX.4.21.0106190817360.16998-100000@homer.atm.ox.ac.uk>, Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
>> I think you might need to add the path to your default .profile/.login/.cshrc/.whatever
>> (which I am assuming you're not doing - I really can't tell from "I tried to append the
>> /usr1/guest/bin/ directory to my UNIX path before starting an IDL session")
>>
>> I *think* when you use SPAWN, the subsequent shell in which the SPAWN command argument is
>> executed is *not* the one you started IDL in and therefore has no knowledge of what you
>> may have explicitly defined. The same sort of thing happens in make files in Unix.
>
> Paulv is indeed correct here. Using spawn will start a *new* process
> (with a unique pid) and therefore it does not interact or have any
> knowledge of the shell or environment variables you had when you started
> IDL.

That's not quite right. When a new process is started it gets the same environment
as its parent (that's the purpose of environment variables in contrast to "normal"
variables). When you exec another executable with exec() or execl() it will still
have the same environment. You can use execvp(), execlp() and pass it a different
environment if required.

If the process created exec's a shell which invokes a startup script such as .profile,
.cshrc, .login etc which has hardcoded environment settings in it (e.g. path=/adf:/dea)
then this will override the environment passed down from the parent.


--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
Re: IDL and UNIX setenv [message #25511 is a reply to message #25428] Tue, 19 June 2001 00:25 Go to previous message
Randall Skelton is currently offline  Randall Skelton
Messages: 169
Registered: October 2000
Senior Member
> I think you might need to add the path to your default .profile/.login/.cshrc/.whatever
> (which I am assuming you're not doing - I really can't tell from "I tried to append the
> /usr1/guest/bin/ directory to my UNIX path before starting an IDL session")
>
> I *think* when you use SPAWN, the subsequent shell in which the SPAWN command argument is
> executed is *not* the one you started IDL in and therefore has no knowledge of what you
> may have explicitly defined. The same sort of thing happens in make files in Unix.

Paulv is indeed correct here. Using spawn will start a *new* process
(with a unique pid) and therefore it does not interact or have any
knowledge of the shell or environment variables you had when you started
IDL. You might be able to pass the IDL '!PATH' variable in a string when
you use spawn, but you'll need to be careful this concatenated string of
path + command doesn't get too long. Modifying your .login/.cshrc to
append the required path is the cleanest option by far.
Re: IDL and UNIX setenv [message #25516 is a reply to message #25428] Mon, 18 June 2001 10:49 Go to previous message
Daniel Peduzzi is currently offline  Daniel Peduzzi
Messages: 29
Registered: June 1999
Junior Member
Paul van Delst wrote in message <3B2E3157.F8C80B51@noaa.gov>...
>
> I think you might need to add the path to your default .profile/.login/.cshrc/.whatever
> (which I am assuming you're not doing - I really can't tell from "I tried to append the
> /usr1/guest/bin/ directory to my UNIX path before starting an IDL session")
>


That did it! I'm starting IDL through csh, so extending the PATH through
.cshrc did the trick. (You assumed correctly...I had been extending the
path via setenv at the csh prompt.)

> I *think* when you use SPAWN, the subsequent shell in which the SPAWN command
> argument is executed is *not* the one you started IDL in and therefore has no
> knowledge of what you may have explicitly defined. The same sort of thing
> happens in make files in Unix.

I think you're right...thanks for the tip!

Dan
Re: IDL and UNIX setenv [message #25518 is a reply to message #25428] Mon, 18 June 2001 09:50 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Daniel Peduzzi wrote:
>
> I have an executable (compiled from C) which I'd like to
> run from within IDL using SPAWN. However, I'd like to refer
> to the executable without prepending a pathname:
>
> IDL> spawn, "myprog", result
>
> instead of
>
> IDL>spawn,"/usr1/guest/bin/myprog", result
>
> I tried to append the "/usr1/guest/bin/" directory to my UNIX
> path before starting an IDL session, but the path information
> doesn't seem to be propagated into IDL.
>
> What else, if anything, can I do to get IDL to find "myprog"?

I think you might need to add the path to your default .profile/.login/.cshrc/.whatever
(which I am assuming you're not doing - I really can't tell from "I tried to append the
/usr1/guest/bin/ directory to my UNIX path before starting an IDL session")

I *think* when you use SPAWN, the subsequent shell in which the SPAWN command argument is
executed is *not* the one you started IDL in and therefore has no knowledge of what you
may have explicitly defined. The same sort of thing happens in make files in Unix.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: regression with poisson models
Next Topic: 10 bit packed as 8 bit unpacking

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:37:18 PDT 2025

Total time taken to generate the page: 0.00426 seconds