view master/bin/internal/invoke.sh @ 10:2fbefb8d1a9e

wrun.sh: usage catchup invoke.sh: force terminal allocation on workers test1.sh: support control of number of worker processes are spawned, support -t to turn off random delay at startup count1.sh: actual do the counting in subprocs to avoid disk contention
author Henry S. Thompson <ht@markup.co.uk>
date Mon, 08 Oct 2018 13:17:23 +0000
parents 55e953e5c66f
children 9275e2a8b5e2
line wrap: on
line source

#!/bin/bash
# Helper for ../wrun, q.v.
# Usage: invoke.sh [-x] me cmd ifile id port ip [args...]
#  Runs 
#   cmd [id] args...
#  via ssh to ip:port
#  If ifile is not /dev/null, feed in as stdin
#  Unless -x, worker id is passed as first arg
if [ "$1" = "-w" ]
then
 shift
 wait=1
fi
if [ "$1" = "-x" ]
then
 shift
 id=
 me=
else
 me=$1
 id=$4
fi
cmd="$2"
ifile=$3
port=$5
ip=$6
shift 6
echo "#$(date)#$cmd#$ifile#$id#$port#$ip#$@#" 1>&2
if [ "$ifile" != "/dev/null" ]
then
  echo "# from $ifile" 1>&2
  scp -P $port $ifile $ip:ifile.txt
fi || echo scp failed, status=$? 1>&2
if [ "$wait" ]
then
  ssh -tt -p $port $ip "nohup $cmd $id $me ""$@"" > nohup.cc"
else
  ssh -p $port $ip "$cmd $id $me ""$@"
fi || echo ssh failed, status=$? 1>&2
echo "#$(date)#$id#" 1>&2