#!/usr/bin/ksh #Get date; find month's name and make the appropriate file #month=`date -u +%m'` month="july" year=`date -u +%Y'` case $month in 01) month_name="january" file_name="$month_name$year.html" dir_name="$month_name$year";; 02) month_name="february" file_name="$month_name$year.html" dir_name="$month_name$year";; 03) month_name="march" file_name="$month_name$year.html" dir_name="$month_name$year";; 04) month_name="april" file_name="$month_name$year.html" dir_name="$month_name$year";; 05) month_name="may" file_name="$month_name$year.html" dir_name="$month_name$year";; 06) month_name="june" file_name="$month_name$year.html" dir_name="$month_name$year";; 07) month_name="july" file_name="$month_name$year.html" dir_name="$month_name$year";; 08) month_name="august" file_name="$month_name$year.html" dir_name="$month_name$year";; 09) month_name="september" file_name="$month_name$year.html" dir_name="$month_name$year";; 10) month_name="october" file_name="$month_name$year.html" dir_name="$month_name$year";; 11) month_name="november" file_name="$month_name$year.html" dir_name="$month_name$year";; 12) month_name="december" file_name="$month_name$year.html" dir_name="$month_name$year";; esac # For each .dat in most_recent, the file gets moved to the appropriate # month. The .gif files found in /plot1 and /plot2 are also moved. #cd /disks/soleil/home/www/hessi/data/spectrometer/plots/archive/temp mostrecent=$(ls *.dat | tail -1) for datfile in *; do if [[ -f $datfile ]] && [[ $datfile = *.dat ]]; then if [[ $datfile != "$mostrecent" ]]; then giffile=${datfile%dat}gif # mv "$datfile" "../$dir_name/$datfile" # cp "plot1/$giffile" "../$dir_name/plot1/$giffile" # cp "plot2/$giffile" "../$dir_name/plot2/$giffile" cd ../$dir_name # At this point, we try to find the starting and ending date/time for # each file. It find the first element of each line, looking for the # appropriate lines (they must begin with a 1 or 0). After we have a # variable consisting of all the first tokens of every line, we must # get the first and last ones (after first removing an extra space at # the beginning of the variable). Now, we have a starting/ending # "chunk" that looks like: mo/dd_hh:mm. We separate the month from # the time. firsttokens="" while read firsttoken restofline; do if [[ $firsttoken = 0* ]] || [[ $firsttoken = 1* ]]; then firsttokens="$firsttokens $firsttoken" fi done < $datfile firsttokens=$(print "${firsttokens# }") startchunk=$(print "${firsttokens%% *}") endchunk=$(print "${firsttokens##* }") startdate=$(print "${startchunk%_*}") enddate=$(print "${endchunk%_*}") starttime=$(print "${startchunk#*_}") endtimetemp=$(print "${endchunk#*_}") # For some strange reason, the "read" command does not tend to get the # last line in a file, unless there is a blank line after it. For this # reason, all of our end times will be off by one minute. So, we add # a minute to endtimetemp to find the real endtime. endminutetemp=$(print "${endtimetemp#*:}") endhourtemp=$(print "${endtimetemp%:*}") ((endminute = endminutetemp + 1)) if [[ $endminute = "60" ]]; then ((endhour = endhourtemp + 1)) endtime="$endhour:00" else endtime="$endhourtemp:$endminute" fi cd .. # FINALLY!!! We're ready to start the html file. print "" >> "center" print "$startdate" >> "center" print "$starttime" >> "center" print "$enddate" >> "center" print "$endtime" >> "center" print "Plot 1Plot 2" >> "center" print "$datfile" >> "center" print "\n" >> "center" cd /disks/soleil/home/www/hessi/data/spectrometer/plots/archive/most_recent fi fi done while read -r line; do print $line done < "../header" > "../$file_name" for file in "../center" "../footer"; do while read -r line; do print $line done < $file >> ../$file_name done