There are hints that this can be done with the IRAF CL, although the only clue I have found is this nearly 20 year old page that warns that this is "still a primitive feature of the OpenIRAF project in development". They claim it is functional, but I have not yet been able to make it work.
So far, I always end up with the "cl" prompt rather than having it execute the script in the file.The forum discussion says that this should appear on the shebang line:
#!/iraf/iraf/bin.linux/ecl.e -fAnd indeed this works, the recipe in the first link is embryonic and out of date.
Another option is to just run the desired IRAF task directly. The following excerpt tells how to do this from the csh:
There are three ways to run an IRAF task outside of the CL, either invoke the executable directly with the correct command line arguments, run the CL with the input redirected to execute the task, or use the host CL scripting capability.In the first case you must know in which executable the task resides, core IRAF system tasks (e.g. things in the PLOT and IMAGES packages) have their executables in the main $iraf/bin.
directory, NOAO package tasks have the executables in the $iraf/noao/bin. directory. There is usually a separate executable for each package and you can probably figure out which one goes for each package otherwise just look at the package cl file to find out, for example the PLOT package defines the task in the $iraf/pkg/plot/plot.cl file, if you look in their you'll see that is defines the tasks as (part of the file reads) task contour, surface, hafton, velvect = "plot$x_ncar.e"which means that the CONTOUR, SURFACE, etc tasks are in the "x_ncar.e" executable.Once you find the correct binary, you need to create a file with the task parameters: usually it's easiest to set the parameters and then dump the parameter file with 'dpar', e.g.
cl> dpar listpix > listpix.parThen to run the task you would do something like:% $iraf/bin.sparc/x_images.e listpix @listpix.parIn this case you must be careful that ALL of the task parameters are defined, this is done by 'dpar' but empty string parameters will be prompted for.In the second case you create a command file and input it to the cl, for example
% cl < cl.input >& some_logfilewhere cl.input contains CL commands such aswfits.scale=no # set a parameter wfits image*.imh mta # call a task logout # logout of the CLYou must be careful about making sure you are in the right directory and that parameters are given explicitly if they're like to change, but with this approach you can call any iraf task.In both cases you need to be careful about redirecting any input or output that is required, both text and graphics. You can redirect graphics output either by setting the "device" parameter to e.g. 'stdvdm' or using the '>G' syntax as in
cl> surface dev$pix >G surf.plot cl> surface dev$pix dev="stdplot" # to print it out cl> surface dev$pix dev="stdvdm" # save metacode to uparm dirThe host CL scripting capability is covered in another part of this FAQ. Which of these approaches works best for depends depends on the tasks you need and the complexity of the script. Note that by using OS escapes in IRAF scripts it may be simpler to write an IRAF script to do the same thing.
Tom's home page / tom@mmto.org