View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Creating text files in scripts

Nostril585129 wrote on Dec 10, 2008

Hello there! This is my first post, but I've been reading the forum for weeks. You guys have been great helping me to understand IRAF.

My problem has to do with having my cl script output a package's results to a text file. When not in a script, I often use syntax such as:

imheader imlist=fitsimage lo+ > headerinfo.txt

which will create a text file named headerinfo.txt. If I wish to do the same in a cl script (since I must use program langauge) I would type something like:

imheader (imlist="fitsimage" longheader="yes" ) > headerinfo.txt
OR
imheader (imlist="fitsimage" longheader="yes" > headerinfo.txt)

but both of them yield syntax errors. Any help on how to create a text file from the output of a package? Imheader puts out many many lines of data and i want to put it all in a text file.

Thanks so much!

Mike Fitzpatrick wrote on Dec 10, 2008

imheader (imlist="fitsimage" longheader="yes" > headerinfo.txt)


This is the closest to what you want, but you need to remember that the various parameters are separated by commas in 'program mode', and since you're using a literal filename you need to enclose it in quotes. Try e.g.


imheader (imlist="fitsimage", longheader="yes", > "headerinfo.txt") 


Note the comma before the redirection (which is considered as another argument to the task).

If your intent is to extract specific header keywords then you may want to consider using HSELECT and "scan from pipe", e.g.

hselect ("dev$pix", "object", yes) | scan (objname)


where 'objname' is a local script variable.

-Mike

Nostril585129 wrote on Dec 10, 2008

Thanks so much! That worked out perfectly!

Last post on Dec 10, 2008