View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Writing to file from a procedure script

Gabriel wrote on Mar 12, 2009

I need a way to automatically (i.e. from a script) create a file and write the following text into it:

char : text1 text2 text3
char2 : text4 text5 text6

something along those lines (it's the 'imsets' file from 'mknobsfile'). Can this be done with a script or do I have to do it manually?

Mike Fitzpatrick wrote on Mar 12, 2009

Use a print statement and redirect it to a file, e.g.


print ("char : text1 text2 text3",  > "imsets")
print ("char2 : text4 text5 text6", >> "imsets") 


Note the filename 'imsets' is quoted as a literal string, the >> operator is used to append a file.

-Mike

Gabriel wrote on Mar 12, 2009

Thanks Mike. One more question if you don't mind. This is a transcript from the 'mkconfig' help:

transform
The source of the transformation equations definition. Transform may be the name of one of the supported standard star catalogs maintained in the directory "photcal$catalogs/", the standard input "STDIN", or a file created by the the user containing the transformation equations definition. Transform is not prompted for if template is "".

template = ""
The name of an existing configuration file that can be used as a template for the new configuration file. If template is the null string "", then MKCONFIG prompts the user for the source of the standard star catalog and observations file format descriptions catalog and observations, and the source of the transformation equation definitions transform. If template exists, MKCONFIG copies template into config and enters the editor if edit is "yes".

So transform is or is not prompted if template is ""?

Mike Fitzpatrick wrote on Mar 12, 2009

According to the source code, if template="" then you will still see a prompt for the 'transform' parameter, but the transform param is allowed to still be a null string.

-Mike

Last post on Mar 12, 2009