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

Home » Public Forums » archive » How to set environment variables in IDLDE
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
How to set environment variables in IDLDE [message #74407] Tue, 11 January 2011 07:56 Go to next message
mankoff is currently offline  mankoff
Messages: 131
Registered: March 2004
Senior Member
Hi,

I usually run IDL from the command line and it inherits all the
environment variables I have in my .profile. This allows me to, for
example, "spawn, 'foo'" where foo is in my unix PATH, and foo is
found. When I run the IDLDE by double-clicking on the icon, this does
not work.

I've found the suggestion to create a ~/.MacOSX/environment.plist file
and put my path there. This has caused all sorts of other problems.

Is there a way in the IDLDE, or via IDL commands (I can put them in my
startup.pro file), for me to generally get my environment into the
IDLDE or specifically append my PATH statement so that some unix tools
can be found by SPAWN?

Thanks,

-k.
Re: How to set environment variables in IDLDE [message #94903 is a reply to message #74407] Wed, 29 November 2017 10:28 Go to previous message
Luke is currently offline  Luke
Messages: 4
Registered: October 2006
Junior Member
I know this is a really old thread, but since this is where I landed in my great search on this issue.. in 2017.. I figured I'd post my solution since I cannot seem to make anything else work. This is code you can put in your startup.pro file, and it assumes you declare your environmental vars with the export command in your .bash_profile. Change the relevant lines as needed. Works like a charm for me.. after all these years of declaring pathnames explicitly for all my scripts run in my IDLDE environment.

;Set user environmental variables
file = getenv('HOME')+path_sep()+'.bash_profile'
line = ''
openr, lun, file, /get_lun
while not eof(lun) do begin & $
readf, lun, line & $
if strcmp(line, 'export ', 7, /fold_case) then begin & $
temp = strsplit(strmid(line, 7), '=', /extract) & $
env = strsplit(temp[1], path_sep(), /extract, count=n) & $
for ienv=0, n-1 do $
if strcmp(env[ienv], '$', 1) then $
env[ienv] = getenv(strmid(env[ienv],1)) & $
if product(strlen(env) gt 0) then $
setenv, temp[0]+'='+strjoin(env, path_sep()) & $
endif & $
endwhile
free_lun, lun
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Context Menu ib widget_tree
Next Topic: CURSOR without mouse

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

Current Time: Wed Oct 08 13:38:29 PDT 2025

Total time taken to generate the page: 0.00480 seconds