> At the IRAF Developers' Workshop, it was mentioned that there > is a variant of the IRAF/CL that can operate as a Unix shell. Yes, as a unix "interpreter file", see the man page for execve. > My understanding of this was that, given this CL version, one > can invoke IRAF/CL scripts from a Unix script with a #! /cl Yes. > Can you tell me how to get this version of the CL and perhaps an > example of how it's been used? Currently there is only an internal prototype that is used for the NOAO hourly weather archive and for pipeline processing of daily NSO images. A hello world example: #!/iraf/iraf/bin.sparc/cl.e -f printf ("Hello, world, from the land of IRAF!\n") logout % hello Hello, world, from the land of IRAF! Unix limits the first line of the script to 32 characters, so keep your iraf paths short. The script has to establish all of its own context, such as the machine architecture. Each individual package may come with such context, too, the most obvious being the images package which checks the IRAF version when loaded, resulting in the usage below. An imdelete example: #!/iraf/iraf/bin.sparc/cl.e -f if (defpar ("logver")) logver = "IRAF V2.10EXPORT April 1992 revision 1" ; images imdelete ($args) logout In the prototype, the $args parameter is used to pass the unix command line arguments into the script - it's handy to scan this into separate parameters. Image templates (*.imh) and such must be quoted on the command line to protect them from expansion by the parent unix shell. Note that these are not procedure scripts, hence the semi-colon after the `if' block above to work around that ancient bug. Other than the things mentioned and an environment variable that has to be set to locate the cl.par file for the prototype (since it isn't the installed version), I've found this to be a solid way of scripting for host level chores. The scripts are no more hairy than perl, for instance - actually much more straightforward if you happen to already know IRAF. > Would it be possible for us to get a copy of your prototype? Sure, it's now available in ftp://iraf.noao.edu/misc/hashbang_cl.tar.Z. Unpack the tar file into some .bin subdirectory that is not very deeply nested. The path to the executable has to fit into 27 characters - the 32 that the system allows minus two for "#!", minus three for the " -f" argument that specifies the startup file. The basic mechanism is just to source a file different from login.cl at startup via the "-f" argument. As with all unix interpreter file scripts, the call to exec just redirects the executable to the one specified when passed a file beginning with the magic number "#!" - the current filename is passed to the interpreter as the first argument, followed by whatever was specified on the command line. The interpreter (e.g., the CL or perl or whatever) is required to treat the initial "#" as a comment, so it then proceeds to ignore the first line of the script that served to bootstrap the whole process. The tar contains six files: rwxr-xr-x354/10 999424 Feb 8 13:52 1995 ./cl.e rw-r--r--354/10 1840 Feb 8 14:06 1995 ./cl.par rwxr-xr-x354/10 47 Feb 8 15:28 1995 ./exit_status rwxr-xr-x354/10 84 Feb 8 14:09 1995 ./hello rwxr-xr-x354/10 139 Feb 8 14:10 1995 ./imstat rw-r--r--354/10 52 Feb 8 14:13 1995 ./source.me The cl.e is a statically linked IRAF v2.10.2 CL. The parameter file is the normal file with the addition of the $args parameter which is initialized with the unix command line arguments. There are three example scripts, hello, imstat, and exit_status. Hello is pretty obvious. Imstat runs the imstatistics task on the images specified - be careful passing wild cards from the unix shell. The third example, exit_status, shows how to explicitly pass a unix exit status back from the script using a modified logout command: % cat exit_status #!/home/seaman/bin/cl.e -f logout (int($args)) % exit_status 13 % echo $status 13 This exit status may or may not be useful to you - it isn't integral to the basic mechanism. There are two environment variables that have to be declared before running any scripts: setenv cldir /home/seaman/bin/ setenv arch .sparc Set cldir to your own pathname, of course - also edit this path into the first line of each script. I would definitely *not* try to build anything durable with this, but it should be fine for experimental purposes. > This approach however has the drawback that there is overhead of > invoking the CL and loading packages everytime IRAF tasks are invoked. > I guess it's a trade-off. One can script in IRAF and reduce the CL > overhead, or one can script in UNIX and pay the CL overhead price > for each IRAF task invocation. Well the #! scripts reduce this to a minimum since the normal login.cl is never sourced, unlike merely redirecting the standard input of the CL from a script. Another alternative, that avoids running the CL at all, is to call each IRAF executable from the host level: % /gemini/iraf/iraf/bin.sparc/x_system.e directory $nargs: 0 long: yes maxch: 18 sort: yes all: no xb-rwr-r- seaman 999424 Feb 8 13:52 cl.e -t-rwr-r- seaman 1840 Feb 8 14:06 cl.par xt-rwr-r- seaman 47 Feb 8 15:28 exit_status xt-rwr-r- seaman 84 Feb 8 14:09 hello xt-rwr-r- seaman 139 Feb 8 14:10 imstat -t-rwr-r- seaman 52 Feb 8 14:13 source.me This can be streamlined by referencing the parameters in a file generated with the dparam task: cl> dparam directory directory.files = "taupe!/data1/36inch/n5" directory.long = no directory.ncols = 0 directory.maxch = 18 directory.sort = yes directory.all = no directory.mode = "ql" # EOF Put this in a file directory.dparam (and edit the particular values, including $nargs): % cat directory.dparam directory.$nargs = 0 directory.long = yes directory.ncols = 0 directory.maxch = 18 directory.sort = yes directory.all = no directory.mode = "ql" # EOF and you can run that as: % /iraf/iraf/bin.sparc/x_system.e directory @directory.dparam xb-rwr-r- seaman 999424 Feb 8 13:52 cl.e -t-rwr-r- seaman 1840 Feb 8 14:06 cl.par -t-rwr-r- seaman 151 Feb 8 16:03 directory.dparam xt-rwr-r- seaman 47 Feb 8 15:28 exit_status xt-rwr-r- seaman 84 Feb 8 14:09 hello xt-rwr-r- seaman 139 Feb 8 14:10 imstat -t-rwr-r- seaman 52 Feb 8 14:13 source.me That there is no CL associated with this makes it more difficult to do graphical chores since you have to manually dump intermediate results into metacode files.