#! /bin/csh -f ################################################################### ################################################################### # Cshell script which sets up a series of parameters and # starts IRAF in a new XGTerm. # # Version 3.12 # # Usage: xiraf -h # # Author: Vassilis Charmandaris # E-mail: vassilis@astro.cornell.edu # URL: http://www.astro.cornell.edu/~vassilis # # Date: Tue Aug 3 15:46:12 EDT 2004 # Info: Like IRAF there is no copyright for this script. You may # redistribute and modify it according to your needs. # However, please keep a reference to the original developer # and mention the web page where more information on this # script can be found: # http://www.astro.cornell.edu/~vassilis/xiraf/ ################################################################### ################################################################### # # BASIC SYSTEM VARIABLE DEFINITIONS # ================================= # # Unalias some Unix commands we'll use just in case ... # ----------------------------------------------------- unalias rm rmdir mkdir cd mv ln setenv cat echo # # Define the Unix command which creates the fifo files #----------------------------------------------------- setenv MAKE_FIFO /bin/mknod # This has to be defined by the user since the directory where the # mknod command resides is architecture dependent and sometimes it's # not in the PATH of the user. Try "where mknod" to find it. # For RedHat Linux it's at "/bin/mknod". # #--- # # Define the name of a temporary file where a series of commands # will be placed. The file will be deleted at the end of your IRAF # session. A good choise would be a name associated with the user # who runs the xiraf script located in the /tmp directory. #---------------------------------------------------------- setenv START_IRAF "/tmp/start_iraf_""`whoami`" # # Define some IRAF and OS related parameters #------------------------------------------- # The following two are essential. See the IRAF installation # guide for more information. setenv iraf /iraf/iraf/ setenv IRAFARCH redhat # Possible values for IRAFARCH are: # SunSolaris -> ssun # SunSparc -> sparc # DEC-OSF/1 -> alpha # DEC-Ultrix -> ddec # etc... # # NOTE: Linux users may notice that the image display window # (say SAOimage, Ximtool etc) does not close when one exits # xiraf. This is a Linux bug which does not kill background # child processes once the xgterm shell dies. A practical # workaround fix is to add a few lines to to xiraf script # which search for the process and kill it. This has been done # further down this script. For details search for the word # "kill" or send an e-mail to: vassilis@astro.cornell.edu # # The next two are rather cosmetic ... setenv OS_TYPE `uname` setenv IRAF_VER "2.12.2a" # # Define the filesystem of the users disk #---------------------------------------- setenv MYFILSYS "NFS" #setenv MYFILSYS "AFS" # # Most sites do not have to worry about this since most places use # NFS (=Network File System) as their Unix filesystem. # # However, there is also the AFS (=Andrew File System) which does not # permit the creation of fifo files on its volumes. In that case the # personal fifo files of the users have to be recreated everytime and # stored to the /tmp disk of the workstation they are working. # # If a site has both AFS and NFS disks then the variable MYFILESYS has # to be calculated on the fly. Contact me for suggestions. # # Define the directory where X11IRAF is installed and version used #------------------------------------------------------------------ setenv X11IRAF_DIR /iraf/extern/x11iraf setenv X11IRAF_VER "1.3.1" # # Define the directory where the SAOImage is located and version used #-------------------------------------------------------------------- setenv SAOIMAGE_BINDIR /iraf/extern/bin setenv SAOIMAGE_VER "1.35.1" # # Define the directory where DS9 is installed and version used #--------------------------------------------------------------- setenv DS9_DIR /iraf/extern/bin setenv DS9_VER "3.0.1" # # NOTE: To be able to change the image buffer size in DS9 you # should make sure that a copy of the IRAF imtoolrc file # is located under /usr/local/lib/ # Apparently this is only necessary for DS9. The other image # display programs can function under the xiraf script # even when this is not done. # # If you don't have DS9 in your system then remove the comment # from the next line : # #setenv NO_DS9 1 # # # Also modify the options message of the script # xiraf which follows. # # Define the syntax of the script xiraf #--------------------------------------- # The following options message is echoed as an error or help message. # setenv OPTIONS_MSG "-h | -help | -ximtool | -saoimage | -saotng | -ds9 | -rebuild" # # # NOTE: # The user has the option to select a default image display client. # --------------------------------------------------------------------- # The user can define an enviroment variable IRAF_DISP in # his/her ~/.cshrc file with the following values: # # setenv IRAF_DISP XImtool # to have XImtool as default # setenv IRAF_DISP SAOimage # to have SAOimage as default # setenv IRAF_DISP DS9 # to have DS9 as default # # If undefined the default image display is set by the system manager # in the if...then statement that follows. # # All clients can be selected interactively from the command line # ---------------------------------------------------------------------- # Get the arguments from the command line set n = 1 if ( $#argv == 0 ) then set n = 0 if ( $?IRAF_DISP == 0) then # If IRAF_DISP undefined the system manager should select # the default image display: setenv IRAF_DISP "XImtool" #setenv IRAF_DISP "SAOimage" #setenv IRAF_DISP "DS9" endif else if ( "$argv[$n]" == "-help" ) then echo "Usage: xiraf ["$OPTIONS_MSG"]" exit 1 else if ( "$argv[$n]" == "-h" ) then echo "Usage: xiraf ["$OPTIONS_MSG"]" exit 1 else if ( "$argv[$n]" == "-ximtool" ) then setenv IRAF_DISP "XImtool" else if ( "$argv[$n]" == "-saoimage" ) then setenv IRAF_DISP "SAOimage" else if ( "$argv[$n]" == "-ds9") then if ( $?NO_DS9 == 1) then echo "The DS9 executable has not been installed \!" echo "Usage: xiraf ["$OPTIONS_MSG"]" exit 1 else setenv IRAF_DISP "DS9" endif else if ( "$argv[$n]" == "-rebuild") then cat << REBUILD_MSG_1 ********************************************************* Are you REALLY sure you want to do this ? If you are runing xiraf for the first time you SHOULD NOT use this option. I assume that there was an upgrade or change of the version of IRAF that you are using and you want to rebuild your login.cl file. To ABORT now press -C and then RETURN or ENTER If you really want to proceed just press RETURN or ENTER As a result your login.cl file will be renamed to login.cl.OLD and the script will recreate a new one for you. ********************************************************* REBUILD_MSG_1 set pause = $< if ( ! -e $USERIRAF/login.cl ) then # There is no existing login.cl file cat << END_ERROR_REBUILD ******************************************************* There is no login.cl file in the \$USERIRAF directory: $USERIRAF Are you sure that \$USERIRAF is defined properly ? If you are using xiraf for the first time just execute the script with no options for more instuctions. ******************************************************* END_ERROR_REBUILD exit 1 else cd $USERIRAF mv login.cl login.cl.OLD cat << REBUILD_MSG_2 ******************************************************* OK! I renamed your login.cl file to login.cl.OLD and I'm now starting once more the "xiraf -ximtool" script which will detect that there is no login.cl file and will remake one for you. Don't worry about the "File exists" messages which may appear. These are due to the fact that the fifo files and some directories were already set up. ******************************************************* REBUILD_MSG_2 # Restart xiraf to recreate login.cl. xiraf -ximtool exit 1 endif else echo "Usage: xiraf ["$OPTIONS_MSG"]" exit 1 endif # # # Load the X-resources of XGterm #------------------------------- # Modification suggested by Wagner Corradi (16-7-2004) to allow # different X-resources location for the xgterm # if ( -e \$X11IRAF_DIR/app-defaults/XGterm) then xrdb -merge $X11IRAF_DIR/app-defaults/XGterm else if (-e /usr/lib/X11/app-defaults/XGterm ) then xrdb -merge /usr/lib/X11/app-defaults/XGterm else cat << END_ERROR_MESSAGE_4 ************************************************************* Your X-resources of XGterm are not located neither under $X11IRAF_DIR/app-defaults/XGterm nor /usr/lib/X11. To proceed, check out where the app-defaults/XGterm is located, and change the path in the line: xrdb -merge /usr/lib/X11/app-defaults/XGterm so that it resembles something like: xrdb -merge /your_path/app-defaults/XGterm To ABORT now press -C otherwise press RETURN or ENTER ************************************************************** END_ERROR_MESSAGE_4 set pause = $< endif # # # END OF SYSTEM VARIABLE DEFINITIONS # ================================== # # Normally one does not have to change anything beyond this point. # ################################################################### ################################################################### # # Now check that some essential variables were defined properly. # if ( ! -e $X11IRAF_DIR/bin/xgterm ) then cat << X11IRAF_ERROR ******************************************************** I could not find xgterm in the \$X11IRAF/bin directory. so I quit !! Please verify that the X11IRAF distribution is installed properly, and that xgterm and ximtool can be found in the directory \$X11IRAF/bin. Under X11IRAF ver. 1.2 the binary directory is named as bin.arch, where arch is the operating system used. You will have to create a symbolic link to a directory named bin to get the script to work. ******************************************************** X11IRAF_ERROR exit 1 endif if ( ! -e $DS9_DIR/ds9 & $?NO_DS9 == 0) then cat << DS9_ERROR ****************************************************** I could not find ds9 in the directory \$DS9_DIR so I quit !! Please verify that the ds9 executable exists in the above directory. If you do not have DS9 in your system, define the variable NO_DS9 as indicated earlier in the script. ****************************************************** DS9_ERROR exit 1 endif ################################################################### ################################################################### # # Before we go any further check that the user has defined an # enviroment variable called USERIRAF. # This should indicate the default directory where the user wants # to place his/her IRAF login.cl and loginuser.cl files as well as # the IRAF subdirectories dev/ and uparm/ . # if (! $?USERIRAF) then # The environment is not defined cat << END_ERROR_MESSAGE_1 ******************************************************* You can not use xiraf just yet .... You must first define an environment variable, USERIRAF, which points to your IRAF home directory, that is the directory where you want to put or, you already have, your IRAF login.cl file. A good choise may be a directory named ~/iraf_params If you use csh or tcsh as your SHELL this can be done by adding the following line to your ~/.cshrc file setenv USERIRAF /full_path/to_the/directory Then source the ~/.cshrc file and run xiraf again ... If you use bash as your SHELL this can be done by adding the following line to you ~/.bash_profile set USERIRAF /full_path/to_the/directory ******************************************************* END_ERROR_MESSAGE_1 exit 1 endif # if ( ! -e $USERIRAF ) then # The environment is not defined but there is no # USERIRAF directory # cat << END_ERROR_MESSAGE_2 ******************************************************** It seems that the USERIRAF directory you have selected: $USERIRAF does not exist. To proceed and create one for you please press on the RETURN or ENTER key to continue... To ABORT now press -C and then RETURN or ENTER ******************************************************** END_ERROR_MESSAGE_2 set pause = $< echo "Creating the directory "$USERIRAF" ..." mkdir $USERIRAF echo "The directory "$USERIRAF" has been created." endif # Since the enviroment variable USERIRAF is there, define the # location where IRAF will search for the private fifo files. setenv IMTDEV fifo:$USERIRAF/dev/imt1i:$USERIRAF/dev/imt1o # ################################################################### # This part makes sure that a user who already had an login.cl file in # his/her account and decides to use xiraf with his/her old login.cl # file gets the extra fifo files needed. if ((! -e $USERIRAF/dev/imt1i) || (! -e $USERIRAF/dev/imt1o)) then # No fifos! # Check to see if there's a login.cl file there if (-e $USERIRAF/login.cl) then # It seems that there's a login.cl file inside $USERIRAF # It looks like the user has been using IRAF before # but he/she is trying xiraf for the first time. # Make the fifos: cat << END_ERROR_MESSAGE_9 ******************************************************** It seems that you had already a login.cl file in your USERIRAF directory but no private fifo files. I assume this is the first time you are trying to use IRAF with the help of the script xiraf. This is a great idea... I'll make your private fifos for you. ******************************************************** END_ERROR_MESSAGE_9 cd $USERIRAF echo " " echo "Creating the directory "$USERIRAF"/dev ..." mkdir dev # # At this point the installation varies depending on the filesystem # (NFS or AFS) of the user. This is necessary since one can not create # pipes in an AFS volume. # # For an AFS user : # if ( $MYFILSYS == 'AFS') then # # Create the fifo files in a subdirectory of the NFS /tmp disk # cd /tmp rm -rf /tmp/`whoami`_iraf mkdir /tmp/`whoami`_iraf cd /tmp/`whoami`_iraf echo "Creating the private fifo files ..." $MAKE_FIFO imt1i p $MAKE_FIFO imt1o p chmod 600 imt1o imt1i cd $USERIRAF/dev rm -rf imt1i rm -rf imt1o ln -s /tmp/`whoami`_iraf/imt1i imt1i ln -s /tmp/`whoami`_iraf/imt1o imt1o # else # # For an NFS user : # cd $USERIRAF/dev echo " " echo "Creating the private fifo files ..." $MAKE_FIFO imt1i p $MAKE_FIFO imt1o p chmod 600 imt1o imt1i echo " " cat << DONE_1 ************************************************************************* I think that the installation of the fifos (imt1o, imt1i) was done properly although I'm not willing to bet my house on it. They are located in the directory $USERIRAF/dev Please check to see that they are there. Now I keep my fingers crossed and I'm trying to start IRAF for you in a new xgterm. The "cl" command which starts IRAF will be executed in it. The image display program you selected (XImtool, SAOimage or DS9) will also start. Once you are at the "cl>" prompt do the following tests to verify that everything is OK. cl> display dev\$pix 1 cl> contour dev\$pix May the FITS be with you and have a nice day ... If the script did work and you liked it thank your system manager for placing this script on your system and send me a message. I would like to keep track how many people are using it. Vassilis Charmandaris vassilis@astro.cornell.edu http://www.astro.cornell.edu/~vassilis ************************************************************************* DONE_1 # endif # filesystem if endif # presence of login.cl if endif # no fifo files if ################################################################### # #################################################################### #################################################################### # # This is the main part where the installation of the personal fifo # files and login.cl file is done. # It's executed only if there is no login.cl file in the directory. # if (! -e $USERIRAF/login.cl ) then # The environment is defined but there is no # login.cl file there. cat << END_ERROR_MESSAGE_3 ******************************************************** It seems that there is no login.cl file in your USERIRAF directory: $USERIRAF To proceed and create one for you please press on the RETURN or ENTER key to continue... To ABORT now press -C and then RETURN or ENTER ******************************************************** END_ERROR_MESSAGE_3 set pause = $< cd $USERIRAF echo " " echo "Creating the directory "$USERIRAF"/dev ..." mkdir dev # # At this point the inistallation varies depending on the filesystem # (NFS or AFS) of the user. This is necessary since one can not create # pipes in an AFS volume. # # For an AFS user : # if ( $MYFILSYS == 'AFS') then # # Create the fifo files in a subdirectory of the NFS /tmp disk # cd /tmp rm -rf /tmp/`whoami`_iraf mkdir /tmp/`whoami`_iraf cd /tmp/`whoami`_iraf echo "Creating the private fifo files ..." $MAKE_FIFO imt1i p $MAKE_FIFO imt1o p chmod 600 imt1o imt1i cd $USERIRAF/dev rm -rf imt1i rm -rf imt1o ln -s /tmp/`whoami`_iraf/imt1i imt1i ln -s /tmp/`whoami`_iraf/imt1o imt1o # else # # For an NFS user : # cd $USERIRAF/dev echo " " echo "Creating the private fifo files ..." $MAKE_FIFO imt1i p $MAKE_FIFO imt1o p chmod 600 imt1o imt1i # endif # From this point on the installation is again the same ... # echo " " echo "Installing IRAF version " $IRAF_VER" ..." cd $USERIRAF # # Hack (Terry Hancock 2001-10/8) to make xgterm only terminal # just answers the question from mkiraf. # mkiraf << TERMTYPE xgterm TERMTYPE # # At this point the instalation is complete. cat << DONE ************************************************************************* I think that the installation was done properly although I'm not willing to bet my house on it. The login.cl as well as private fifo files have been created and they are located in your $USERIRAF and $USERIRAF/dev directories respectively. Please check them to see that they are as you expect. Now I keep my fingers crossed and I'm trying to start IRAF for you in a new xgterm. The "cl" command which starts IRAF will be executed in it. The image display program you selected (XImtool, SAOimage or DS9) will also start. Once you are at the "cl>" prompt do the following tests to verify that everything is OK. cl> display dev\$pix 1 cl> contour dev\$pix May the FITS be with you and have a nice day ... If the script did work and you liked it thank your system manager for placing this script on your system and send me a message. I would like to keep track how many people are using it. Vassilis Charmandaris vassilis@astro.cornell.edu http://www.astro.cornell.edu/~vassilis ************************************************************************* DONE endif ########################################################################### ########################################################################### # # NOW WE ARE READY TO ROLL !!!! # # First we'll create a temporary file which will have all the commands # we need. if (-e $START_IRAF ) then # A file with the same name exists probably due to an # abnormal exit of a previous IRAF session. Remove the file rm $START_IRAF endif cat << START_IRAF_SCRIPT > $START_IRAF #!/bin/csh -f ################################################################### ################################################################### # Cshell script which is called by the script "xiraf" and starts # first the selected image display program (XImtool, SAOimage, # or DS9) and then the usual "cl" command. # # Version 3.12 # # Usage: xiraf -h # # Author: Vassilis Charmandaris # E-mail: vassilis@astro.cornell.edu # URL: http://www.astro.cornell.edu/~vassilis # # Date: Tue Aug 3 15:46:12 EDT 2004 # Info: Like IRAF there is no copyright for this script. You may # redistribute and modify it according to your needs. # However, please keep a reference to the original developer # and mention the web page where more information on this # script can be found: # http://www.astro.cornell.edu/~vassilis/xiraf ################################################################### ################################################################### # # At this point the start-up varies depending on the filesystem # (NFS or AFS) of the user. This is necessary since one can not # create fifo files (a.k.a. pipes) in an AFS volume. # # For an AFS user : # if ( \$MYFILSYS == 'AFS') then # # Create the private fifo files in a subdirectory of the # NFS /tmp disk and then make symbolic links to the # directory \$USERIRAF/dev where IRAF will expect to find them. # cd /tmp rm -rf /tmp/`whoami`_iraf mkdir /tmp/`whoami`_iraf cd /tmp/`whoami`_iraf \$MAKE_FIFO imt1i p \$MAKE_FIFO imt1o p chmod 600 imt1o imt1i cd \$USERIRAF/dev rm -rf imt1i rm -rf imt1o ln -s /tmp/`whoami`_iraf/imt1i imt1i ln -s /tmp/`whoami`_iraf/imt1o imt1o # else # # For an NFS user : # # Do nothing # The private fifo files were already created by the # script xiraf and they are located at \$USERIRAF/dev # endif # # Go to the directory of the personal "login.cl" file #----------------------------------------------------- cd \$USERIRAF # # Start the appropriate image display client #------------------------------------------- if ( \$IRAF_DISP == "XImtool" ) then echo "Starting XImtool version $X11IRAF_VER ..." \$X11IRAF_DIR/bin/ximtool \ -xrm "*input_fifo:\$USERIRAF/dev/imt1i" \ -xrm "*output_fifo:\$USERIRAF/dev/imt1o" & # -cmapDir1 \$X11IRAF_DIR/imtoolcmap & # Uncomment the previous line if you have also installed # the full ximtool colormap. Remember to remove the & # and add a \ in the line just before. else if ( \$IRAF_DISP == "SAOimage" ) then echo "Starting SAOimage version $SAOIMAGE_VER ..." \$SAOIMAGE_BINDIR/saoimage \ -pros -idev ./dev/imt1o -odev ./dev/imt1i & else if ( \$IRAF_DISP == "DS9" ) then echo "Starting DS9 version $DS9_VER ..." \$DS9_DIR/ds9 -fifo ./dev/imt1 & endif # # # Starting IRAF ... source $iraf/unix/hlib/irafuser.csh cl # # Find the window display process (system depended) and kill it. # This is a bug which appears in Linux machines. Normally the # display window should die automatically since it's a child process # within the xgterm. # As the script doesn't know if we use SAOimage, XImtool, # or DS9 we search for and kill all four... # kill -9 \` ps auxw| grep `whoami` | grep saoimage | grep -v grep | awk '{print \$2}' \` kill -9 \` ps auxw| grep `whoami` | grep ximtool | grep -v grep | awk '{print \$2}' \` kill -9 \` ps auxw| grep `whoami` | grep ds9 | grep -v grep | awk '{print \$2}' \` # # # After cl ends you exit IRAF remove the temporary file... rm \$START_IRAF #End of temporary start-iraf script START_IRAF_SCRIPT # Change the mode of the script so that we can excecute it. chmod 755 $START_IRAF # # $X11IRAF_DIR/bin/xgterm -geometry 80x45+530+50 -sb -sl 320 \ -T "XGterm: IRAF v.$IRAF_VER : ($MYFILSYS) : $OS_TYPE" \ -n "IRAF" -e $START_IRAF & echo " IRAF XGterm Window started ..." echo " Starting "$IRAF_DISP" as the image display of your IRAF session ..." exit 0 ########################################################################### ###########################################################################