[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running IDL from cron

Gwyn Fireman wrote:
> How do you run IDL routines from cron - while maintaining IDL_PATH and
> other environment variables?
> I have had no trouble running my idl routines using batch or at, when
> starting in the same directory as the main-level routine.  In that case
> my environment is copied to the spawned process.
> Now I have the need to run these from cron.  I have been able to write
> scripts to cd to the appropriate directory and to run my .cshrc (where
> my IDL_PATH and other environment variables are defined), but keep
> running into problems.  The latest is than .cshrc bombs on a
> system-level env that apparently isn't defined when running from cron.

Craig has given you a good start in a previous post. The other item
which often causes problems when running IDL via cron is that you can't
use graphics windows (unless you are prepared to leave a login session
running all the time).

The solution is to use the Z-buffer, which allows you to emulate the
functionality of an 8-bit graphics window. Let's say you want to call
this procedure (myplot.pro):

plot, x

You'll need an IDL script which sets up the Z-buffer, calls the
procedure, and saves the resulting image (script.pro):

;- Set up Z buffer for 8-bit graphics
set_plot, 'Z'
device, z_buffering=0, set_resolution=[640, 480], $
  set_colors=256, set_character_size=[10, 12]

;- Run my plotting procedure  
myplot, findgen(10)

;- Save the result to a GIF file
tvlct, r, g, b, /get
write_gif, 'myplot.gif', tvrd(), r, g, b

;- Exit IDL

Finally, you need a shell script to configure and run IDL (script.csh):

cd $HOME/myplot
source /usr/local/rsi/idl/bin/idl_setup
setenv IDL_PATH ${IDL_PATH}:+\${IDL_DIR}/user_contrib/jhu_apl
idl script.pro >& script.out

Make sure the shell script has execute permission, and you're done. Test
the script to make sure it works:

% ./script.csh

and you should get the following output in script.out:

IDL Version 5.3 (IRIX mipseb). (c) 1999, Research Systems, Inc.
Installation number: 13221.
Licensed for use by: Space Science & Engineering Cntr, Univ of WI

% Compiled module: MYPLOT.
% Compiled module: WRITE_GIF.
% Loaded DLM: GIF.