View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

implementing cl commands into shell script

taylor wrote on Apr 14, 2017


Hi all,

I am new to IRAF scripting and I have a problem regarding implementing IRAF tasks into a shell script. The script should work with fits files and is very simple, but it has to use IRAF tasks together with bash. The script is as follows:

for i in $( ls ???.fits )

do

rename s/.....$// $i

done

for i in $( ls ??? )

do

mv $i "$i"_6.fits

done

How can I add the cl commands like imcopy (at the beginning of the script) ) and imarith (at the end), so I could run them from bash?

Thanks!!

Mike Fitzpatrick wrote on Apr 25, 2017


IRAF commands are intended to be run from the CL interface since that is what handles things like parameter passing, graphics rendering, etc. IRAF scripts *can* be executed as host level commands (see http://iraf.noao.edu/iraf/web/new_stuff/cl_host.html) and for a simple script such as your example it may be easier to write a CL script than to try to call IRAF binaries directly.

You can call IRAF tasks from unix so long as you know the path to the binary containing the task and can supply the parameters, however this doesn't usually work well for any graphics or interactive tasks or tasks which require iraf environment variables (e.g. the "dev$pix" test image won't resolve the 'dev$' part of the path normally). For example, to run IMCOPY you could use the command:

/iraf/iraf/bin.linux64/x_images.e imcopy input=foo.fits output=bar.fits verbose=no

For tasks with many parameters it is easier to supply the params using the @-file syntax, e.g. in the CL you can dump the params with:

cl\$this->_split2($m[0]) dpar imcopy \$this->_split2($m[0]) imcopy.par

Then edit the 'imcopy.par' file with your values and execute the task as

/iraf/iraf/bin.linux64/x_images.e imcopy @/path/imcopy.par

where you would substitute the iraf path and architecture name appropriate for y

our system.

Information on CL scripting can be found at https://iraf.net/irafdocs/script/

taylor wrote on Jun 13, 2017


Thanks a lot!

Last post on Jun 13, 2017