IRAF script with Linux commands
smp wrote on Mar 17, 2010
Hi,
I have many folders in which fits images are stored in compressed format i.e. .gz files.
What I have to do is: go to each folder, un-compress the .fits.gz files to .fits files, run the task IMSTAT for each of the fits files, store the output (for each folder) in separate .txt file, compress .fits files again to .gz files.
this is my cl script (shown for 2 folders only):
when I run the script, I get the following error:
Regards
smp
I have many folders in which fits images are stored in compressed format i.e. .gz files.
What I have to do is: go to each folder, un-compress the .fits.gz files to .fits files, run the task IMSTAT for each of the fits files, store the output (for each folder) in separate .txt file, compress .fits files again to .gz files.
this is my cl script (shown for 2 folders only):
cd 20090106
!gunzip *.gz
imstat *.fits
!gzip *.fits
cd 20090107
!gunzip *.gz
imstat *.fits
!gzip *.fitswhen I run the script, I get the following error:
ERROR: task `gunzip' not found
cl ()
cl ()
Regards
smp
Mike Fitzpatrick wrote on Mar 17, 2010
Foreign commands like 'gunzip' are executed in a spawned shell, the environment for that shell comes from your .cshrc or .bashrc file depending on the shell used. If the gunzip command isn't being found, then the PATH defined doesn't include the directory where the command lives. You can either edit the file to include a path, or try calling the command explicitly with the path, e.g.
!/usr/bin/gunzip *.gz
imstat *.fits
!/usr/bin/gzip *.fits
smp wrote on Mar 17, 2010
Thanks.
Now (suppose) I have 3 folders. Each folder contains *.fits.gz files as mentioned earlier.
Now names of the folders are: 20090101, 20090102, 20090103.
So I want to write a "for" loop within my cl script so that I can go inside 1st folder, do something, and come out of it, then go inside 2nd folder and so on.
This is my script:
Then I get this error:
Regards,
smp
Now (suppose) I have 3 folders. Each folder contains *.fits.gz files as mentioned earlier.
Now names of the folders are: 20090101, 20090102, 20090103.
So I want to write a "for" loop within my cl script so that I can go inside 1st folder, do something, and come out of it, then go inside 2nd folder and so on.
This is my script:
for(i=1;i<=3;i+=1)
{
if(access("2009010"//i))
{
#list="2009010"//i//".out" # This did not work too
print("2009010"//i) | scan(s1)
cd /igodata/s1
!/usr/bin/gunzip *.gz
imstat (images="*.fits", >> "2009010"//i//".out")
!/usr/bin/gzip *.fits
cd ..
}
} # end of for loopThen I get this error:
ERROR: Cannot change directory to `/igodata/s1'
cd (/igodata/s1)
cl ()
Regards,
smp
Mike Fitzpatrick wrote on Mar 17, 2010
Try using
to concatenate your literal path with the value of the script variable.
-Mike
cd ("/igodata" // s1)to concatenate your literal path with the value of the script variable.
-Mike
smp wrote on Mar 17, 2010
Yes. It works:
Thanks.
smp
cd ("/igodata/"//s1)Thanks.
smp
Last post on Mar 17, 2010