#!/bin/ksh # fetch_data - checks for new data and transfer them to current directory # Syntax: fetch_data [prefix] [check time] # with: # directory at ultra2 : path where integrated data is stored at # check time : duration in sec fetch of new file will be started. # default: 10 sec # prefix : prefix of desired fileset # # Author: Eckart Goehler, IAAT Tuebingen, Germany # 17-07-2001 # # requires: .rhosts must enable access ultra2 without password ############# DATA_DIR=$1 DATA_HOST=ultra2 DATA_HOST_USR=obs12 DATA_LIST="" if [[ $# < 1 ]]; then print "Missing parameter:" print "Syntax: fetch_data data-dir [prefix] [read time]" exit 1 else print "get data from: $DATA_DIR" fi shift if [[ $# = 1 ]]; then PREFIX=$1 shift else PREFIX="" fi if [[ $# = 1 ]]; then DELAY=$2 else DELAY=10 fi print "Read rate: $DELAY" # get all existing files: print "Get all existing files>" while true; do (rsh -l $DATA_HOST_USR $DATA_HOST ls -1l $DATA_DIR/$PREFIX*.fits |\ awk '{print $0, ",";}' ) > filelist.txt filenamelist=$(cat filelist.txt | awk '{print $9;}') for file in $filenamelist; do filename=${file##/*/} if [[ -f $filename ]] ; then filedate=$(ls -l1 $filename | awk '{print $5,$6,$7,$8'}) fi remotefiledate=$( grep "/$filename" filelist.txt | awk '{ print $5,$6,$7,$8;}' ) if [[ ! -f $filename || $filedate != $remotefiledate ]]; then print ' -> ' $filename rcp -p $DATA_HOST_USR@$DATA_HOST:$file . fi done print "Finished." #wait: sleep $DELAY done exit # get all existing files: print "Get all existing files>" while true; do filelist=$(rsh -l $DATA_HOST_USR $DATA_HOST ls -1 $DATA_DIR/$PREFIX*.fits ) for file in $filelist; do filename=${file##/*/} if [[ -f filename ]] ; then filedate=$(ls -l1 $filename | awk '{print $5,$6,$7,$8'}) fi remotefiledate=$(rsh -l $DATA_HOST_USR $DATA_HOST ls -l1 $file | awk '{print $5,$6,$7,$8'} ) if [[ ! -f $filename || $filedate != $remotefiledate ]]; then print ' -> ' $file rcp -p $DATA_HOST_USR@$DATA_HOST:$file . fi done print "Finished." #wait: sleep $DELAY done