Project

General

Profile

Sample samjobsh script

#!/bin/sh

# find ifdhc..
source /grid/fermiapp/products/common/etc/setups.sh ||
  source /cvmfs/oasis.opensciencegrid.org/fermi/products/common/etc/setups.sh
setup ifdhc

# This job assumes it's being passed:
#  $SAM_PROJECT_NAME 
#  $EXPERIMENT
#  $GRID_USER
# and possibly
#  $SAM_STATION
# in the environment via jobsub -e

application="demo" 
version="1" 

cpurl=`ifdh findProject $SAM_PROJECT_NAME ''`
consumer_id=`ifdh establishProcess $cpurl $application $version `hostname` $GRID_USER "" "" "" `
furi=`ifdh getNextFile $cpurl $consumer_id`

status="ok" 

while [ "$furi"  != "" ]
do
    fname=`ifdh fetchInput $furi | tail -1 `
    if [ "$fname" != "" ]
    then
    ifdh updateFileStatus $cpurl  $consumer_id $fname transferred
    if do_something_with $fname
    then
         ifdh updateFileStatus $cpurl  $consumer_id $fname consumed
             ifdh addOutput some_outputfile
    else
         ifdh updateFileStatus $cpurl  $consumer_id $fname skipped
             status="bad" 
        fi
    fi
    rm -f $fname
    furi=`ifdh getNextFile $cpurl $consumer_id`
done
ifdh copyBackOutput /pnfs/$EXPERIMENT/wherever
ifdh setStatus $cpurl $consumer_id  $status