#!/usr/local/bin/perl use Getopt::Std; $dir = "/data/ssf/1/obsred"; $suffix = ".fits"; $maxFile = 9999; getopts('d:s:'); $dir = $opt_d if $opt_d ne ""; $suffix = $opt_s if $opt_s ne ""; $argc = @ARGV; die "Usage: $0 [-d dir] [-s suffix] id date start end\n" if $argc != 4; ($id, $date, $start, $end) = @ARGV; die "'start' must be less than or equal to 'end'\n" if $start > $end; $listFile = "LIST$id"; if ( -f $listFile) { print "File '$listFile' exists. Do you want to overwrite it (y/n)? "; $overwrite = getc; die "File '$listFile' kept.\n" if $overwrite ne "y"; } open(LIST, ">$listFile"); for ($i = $start; $i <= $end; $i++) { $name = sprintf("%s/%s%04d%s", $dir, $date, $i, $suffix); if (-r $name) { print LIST "$name\n"; } else { print "File '$name' not found.\n"; } } close(LIST); # ok, this next bit is a real kludge, but I couldn't think of a nice # way to do it on short notice. for ($i = $end + 1; $i <= $maxFile; $i++) { $name = sprintf("%s/%s%04d%s", $dir, $date, $i, $suffix); if (-f $name) { $endName = sprintf("%s/%s%04d%s", $dir, $date, $end, $suffix); print stderr "Files more recent than '$endName' exist.\n"; last; } } print "File '$listFile' written.\n"; print "Now type:\n"; print " imstack \@LIST$id cube$id\n"; print " blkavg cube$id\[31:60,*,*\] spec$id 30 30 1\n"; print " splot spec$id\n";