Skip to content

Instantly share code, notes, and snippets.

Created June 27, 2013 11:53
Show Gist options
  • Save anonymous/5875875 to your computer and use it in GitHub Desktop.
Save anonymous/5875875 to your computer and use it in GitHub Desktop.
Wrap multiple "cylc suite-state" commands.
#!/bin/bash
#-------------------------------------------------------------------------------
# (C) British Crown Copyright 2012-3 Met Office.
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# NAME
# multi-cylc-suite-state
#
# SYNOPSIS
# multi-cylc-suite-state <<'__STDIN__'
# REG --task=TASK --cycle=CYCLE --run-dir=CYLC-RUN --status=STATUS
# # Each line contains options and arguments of "cylc suite-state"
# __STDIN__
#-------------------------------------------------------------------------------
MY_PIDS=
while read; do
if [[ $REPLY == #* ]]; then
continue
fi
cylc suite-state --wait --timeout=$TIMEOUT $REPLY
MY_PID=$!
if [[ -n $MY_PIDS ]]; then
MY_PIDS="$MY_PIDS $MY_PID"
else
MY_PIDS=$MY_PID
fi
done
RC=0
for MY_PID in $MY_PIDS; do
if ! wait $MY_PID; then
RC=1
fi
done
exit $RC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment