Mercurial > hg > cc > azure
comparison master/bin/internal/invoke.sh @ 30:9275e2a8b5e2
hacking to get id into wbash.sh, maybe buggy?
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Mon, 19 Nov 2018 18:32:30 +0000 |
parents | 2fbefb8d1a9e |
children |
comparison
equal
deleted
inserted
replaced
29:2bde174fe9e2 | 30:9275e2a8b5e2 |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # Helper for ../wrun, q.v. | 2 # Helper for ../wrun, q.v. |
3 # Usage: invoke.sh [-x] me cmd ifile id port ip [args...] | 3 # Usage: invoke.sh [-d] [-w] [-x] me cmd ifile id port ip [args...] |
4 # Runs | 4 # Runs |
5 # cmd [id] args... | 5 # cmd [id] args... |
6 # via ssh to ip:port | 6 # via ssh to ip:port |
7 # If ifile is not /dev/null, feed in as stdin | 7 # If ifile is not /dev/null, feed in as stdin |
8 # If -d, echo command line to stderr | |
9 # If -w, wrap command in nohup and wait for result | |
8 # Unless -x, worker id is passed as first arg | 10 # Unless -x, worker id is passed as first arg |
11 echo $@ 1>&2 | |
12 echo "$@" 1>&2 | |
13 if [ "$1" = "-d" ] | |
14 then | |
15 shift | |
16 debug=1 | |
17 fi | |
9 if [ "$1" = "-w" ] | 18 if [ "$1" = "-w" ] |
10 then | 19 then |
11 shift | 20 shift |
12 wait=1 | 21 wait=1 |
13 fi | 22 fi |
14 if [ "$1" = "-x" ] | 23 if [ "$1" = "-x" ] |
15 then | 24 then |
16 shift | 25 shift |
17 id= | 26 tellid= |
18 me= | 27 me= |
19 else | 28 else |
20 me=$1 | 29 me=$1 |
21 id=$4 | 30 tellid=$4 |
22 fi | 31 fi |
23 cmd="$2" | 32 cmd="$2" |
24 ifile=$3 | 33 ifile=$3 |
25 port=$5 | 34 port=$5 |
26 ip=$6 | 35 ip=$6 |
27 shift 6 | 36 shift 6 |
28 echo "#$(date)#$cmd#$ifile#$id#$port#$ip#$@#" 1>&2 | 37 echo "#$(date)#$cmd#$ifile#$tellid#$port#$ip#$@#" 1>&2 |
29 if [ "$ifile" != "/dev/null" ] | 38 if [ "$ifile" != "/dev/null" ] |
30 then | 39 then |
31 echo "# from $ifile" 1>&2 | 40 echo "# from $ifile" 1>&2 |
32 scp -P $port $ifile $ip:ifile.txt | 41 scp -P $port $ifile $ip:ifile.txt |
33 fi || echo scp failed, status=$? 1>&2 | 42 fi || echo scp failed, status=$? 1>&2 |
34 if [ "$wait" ] | 43 if [ "$wait" ] |
35 then | 44 then |
36 ssh -tt -p $port $ip "nohup $cmd $id $me ""$@"" > nohup.cc" | 45 cs="nohup $cmd $tellid $me "$@" > nohup.cc" |
37 else | 46 else |
38 ssh -p $port $ip "$cmd $id $me ""$@" | 47 cs="$cmd $tellid $me ""$@" |
39 fi || echo ssh failed, status=$? 1>&2 | 48 fi |
49 if [ "$debug" ] | |
50 then | |
51 echo ssh -tt -p $port $ip $cs 1>&2 | |
52 fi | |
53 ssh -tt -p $port $ip "$cs" || echo ssh failed, status=$? 1>&2 | |
40 echo "#$(date)#$id#" 1>&2 | 54 echo "#$(date)#$id#" 1>&2 |