Advertisement
karamaz0v

catjobfile

Jul 15th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #! /bin/bash
  2. ##cat a file for a job writing in node /local
  3.  
  4. script=`basename $0`
  5.  
  6. if [ $# -ne 2 ]; then
  7.    echo "  "
  8.    echo "Usage: $script job_id file"
  9.    echo "  "
  10. else
  11.    job_id=$1
  12.    file=$2
  13.  
  14.    ##verify that job_id is actually running
  15.    checkjob=`qstat | grep -ci " $job_id "`
  16.    if [ $checkjob == 0 ]; then
  17.     printf "!!!!!!! job $job_id  is not running!! \n"
  18.     exit 1
  19.    fi
  20.  
  21.    ## get running node for job_id
  22.    node=`qstat | grep $job_id | sed -n 's/[^@]*@//p' | sed 's/\..*//'`
  23.  
  24.    printf "\n!!!!!!! job is running in \"$node\" node!!\n"
  25.    work_dir=/local/$USER
  26.  
  27.    printf "!!!!!!! start cat at node for file $work_dir/$job_id/$file \n\n"
  28.  
  29.    ### check if file exist in corresponding location; if not exit
  30.    nofile=`rocks run host $node "test -e $work_dir/$job_id/$file && echo 'false' || echo 'true'"`
  31.    if $nofile ; then printf "\n file $work_dir/$job_id/$file  does not exist in node!!! \n\n" ; exit 1 ; fi
  32.  
  33.    ##cat the file!
  34.    rocks run host $node "cat $work_dir/$job_id/$file"
  35.    printf "\n!!!!!!! cat ended\n"
  36. fi
  37.  
  38. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement