#!/bin/sh # the next line starts using tclsh \ exec tclsh "$0" "$@" # # File: fakeLSCdataFind # Author Greg Mendell # # outputs lalcache format like LSCdataFind using an input list of files # Set the name of the cache file with list of files here: set PWD [exec pwd]; set InputFile "$PWD/tmpFramesFullFileList.txt"; exec /ldcg/bin/find /archive/frames/E14/L0/LHO/ | /ldcg/bin/grep gwf | /ldcg/bin/sort > "$InputFile.tmp"; exec mv "$InputFile.tmp" $InputFile; #procedure for printing messages to screen and log file. proc print {String {option "dbl"}} { if {$option == "s"} { puts $String; # Single space output } else { puts $String; # Double space output puts ""; } } proc PrintHelpAndExit {} { global argv0; print "Syntax: $argv0 --gps-start-time endTime --gps-end-time endTime"; print "Will output to stdout a lalcache files for files between input times from list of files given in InputFile which is generated at the top of this code."; print "" "s"; exit; } proc getColumn {Line ColNum} { # Break a Line into columns and return what in column = ColNum. if {$ColNum < 1} { return "No column number given."; } set LineList [split $Line]; set ColumnList ""; foreach ColumnItem $LineList { if {[string trimleft $ColumnItem] > ""} { lappend ColumnList $ColumnItem; } } return [lindex $ColumnList [expr $ColNum - 1]]; # Note first column has index 0. } ##### MAIN CODE STARTS HERE ##### #print "" "s"; #print "Welcome to $argv0"; # Parse command line arguements if {$argv == "" || $argv == "-h" || $argv == "?" || $argv == "--help"} { PrintHelpAndExit; } set type ""; set startTime ""; set endTime ""; foreach element $argv { if {[lindex [split $element "="] 0] == "--gps-start-time"} { set startTime [lindex [split $element "="] 1]; } elseif {[lindex [split $element "="] 0] == "--gps-end-time"} { set endTime [lindex [split $element "="] 1]; } } # Read the input file into Fbuffer. set fid [open $InputFile "r"]; set Fbuffer [read $fid]; close $fid; foreach line [split $Fbuffer "\n"] { if {$line > ""} { set thisFile [lindex [split $line "/"] end]; set thisFileList [split $thisFile "-"]; set thisSite [lindex $thisFileList 0]; set thisType [lindex $thisFileList 1]; set thisStartTime [lindex $thisFileList 2]; set thisDeltaT [lindex [split [lindex $thisFileList 3] "."] 0]; set thisEndTime [expr $thisStartTime + $thisDeltaT]; if { ($thisStartTime < $endTime) && ($thisEndTime > $startTime) } { set outString "$thisSite $thisType $thisStartTime $thisDeltaT file://localhost"; append outString $line; puts "$outString" } } } exit; #### MAIN CODE ENDS HERE #####