View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Fucntion “access” and the task “delete”

smp wrote on Aug 25, 2009

Hi,

(1)

In my procedure script, I delete the unwanted files (text/fits files) as:

e.g.

if(access("*_left.fits")) { delete("*_left.fits") }
else {print("file not found")}

And script fails showing "file not found"

Actually files of this extention (i.e. _left.fits) exist.

and the function "access" was working fine before.
--------------------------------------------------------------------------------------------------

(2)

If, instead, I give the command (in script):

delete("*_left.fits")


there is no problem; files get deleted.
-------------------------------------------------------------------------------------------
(3)

In command mode (on cl prompt), if I give the commands:

cl> =access("*_left.fits")


returning value of function access is : no

while for the command (a particular fits file is HD80606b_B.8639.0.fits_left.fits)

cl> =access("HD80606b_B.8639.0.fits_left.fits")


returning value of access is :yes
-------------------------------------------------------------------------------------------

Please tell me what is the problem with "access" statement in (1) above.

Regards
smp

Mike Fitzpatrick wrote on Aug 25, 2009

The access() function takes a single file name, not a template string. If you want to see whether more than one such file exists, see e.g. the FILES command to expand the list. You can pipe the output to COUNT then check whether more than one match was found, e.g.

files ("*left.fits") | count | scan (nfiles)
if (nfiles > 1) {
    delete ("*left.fits")
}


-Mike

smp wrote on Aug 25, 2009

Thanks Mike.
It worked.

Regards
smp

Last post on Aug 25, 2009