#!/bin/bash # cqrun - a wrapper around Cobalt's qsub and cqwait # # Example: # $ cqrun [--dotfile=foo] -n 1 -q debug -t 20:00 -- some shell command # Note that the "--" is required. # # BUGS: # One can use double-quotes, but not single-quotes, in the shell command # ## Remote path: if [ "x$1" = "x--cqrun-at-remote" ]; then shift if expr "x$1" : "x--dotfile=" >/dev/null 2>&1; then for filename in $(tr ',' ' ' <<<${1##*=}); do source $filename; done shift fi exec env "$@" fi # ## Normal path: cmd='qsub ' helper="$(cd $(dirname $0) && pwd)/$(basename $0) --cqrun-at-remote" while [ $# -ne 0 ]; do word="$1"; shift if expr "x$word" : "x--dotfile=" >/dev/null 2>&1; then helper="$helper $word" else [ x$word = x-- ] && break cmd="$cmd $word" fi done cmd="$cmd -e \\\$jobid.output --mode script $helper \"'$1'"; shift while [ $# -ne 0 ]; do word="$1"; shift cmd="$cmd '$word'" done cmd="$cmd\"" id=$(eval $cmd) cqwait $id sleep 1 cat $id.output rm -f $id.{cobaltlog,output}