Mercurial > hg > cc > azure
annotate master/bin/internal/old_invoke.sh @ 33:4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
towards rework of date fixup
share.sh, old_invoke.sh
recover the old approach to sharing, which works
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Tue, 20 Nov 2018 14:49:07 +0000 |
parents | |
children |
rev | line source |
---|---|
33
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
1 #!/bin/bash |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
2 # Helper for ../wrun, q.v. |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
3 # Usage: invoke.sh [-x] me cmd ifile id port ip [args...] |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
4 # Runs |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
5 # cmd [id] args... |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
6 # via ssh to ip:port |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
7 # If ifile is not /dev/null, feed in as stdin |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
8 # Unless -x, worker id is passed as first arg |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
9 if [ "$1" = "-w" ] |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
10 then |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
11 shift |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
12 wait=1 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
13 fi |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
14 if [ "$1" = "-x" ] |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
15 then |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
16 shift |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
17 id= |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
18 me= |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
19 else |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
20 me=$1 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
21 id=$4 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
22 fi |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
23 cmd="$2" |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
24 ifile=$3 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
25 port=$5 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
26 ip=$6 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
27 shift 6 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
28 echo "#$(date)#$cmd#$ifile#$id#$port#$ip#$@#" 1>&2 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
29 if [ "$ifile" != "/dev/null" ] |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
30 then |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
31 echo "# from $ifile" 1>&2 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
32 scp -P $port $ifile $ip:ifile.txt |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
33 fi || echo scp failed, status=$? 1>&2 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
34 if [ "$wait" ] |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
35 then |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
36 ssh -tt -p $port $ip "nohup $cmd $id $me ""$@"" > nohup.cc" |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
37 else |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
38 ssh -p $port $ip "$cmd $id $me ""$@" |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
39 fi || echo ssh failed, status=$? 1>&2 |
4c117ee8ed75
fixDates, _fixAndMerge, _doFetch
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
40 echo "#$(date)#$id#" 1>&2 |