-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer-target.sh
48 lines (40 loc) · 1.05 KB
/
transfer-target.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/bash
function rcopy()
# from, to_file_path
{
cmd="scp $1 $2"
# echo " cmd: $cmd"
$cmd
}
function rcmd()
# _cmd
{
cmd="ssh $target $1"
# echo " cmd: $cmd"
$cmd
}
executable=$1
executable="${executable%\"}" # quoted with \"
executable="${executable#\"}"
STRIP=strip
stripped=${executable}.stripped
echo "Strip executable $executable (to $stripped)"
$STRIP -v $executable -o $stripped
remote=${executable}.remote
echo "Transfer stripped executable $stripped (as $remote)"
echo -n " Test if stripped is transferred already..."
# Could check for unmodified files... (with md5sum)
# or use alternative method of transfer like rsync.
# simple (and unsafe) approach for now - make a local copy when the
# remote copy succeeded.
if cmp -s $stripped $remote; then
echo " YES (IMHO)"
# echo -n "wake up sshd..."
# rcmd "echo done"
else
echo " NO - start transfer"
while ! ( rcopy "$stripped" "${remote##/*/}" && cp $stripped $remote ); do
rcmd "killall gdbserver"
rcmd "killall -9 $remote" # likely to be straced...
done
fi