-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcardDrop.bash
executable file
·63 lines (42 loc) · 1.62 KB
/
cardDrop.bash
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
arg1=${1:-''}
if [[ $arg1 == '--help' || $arg1 == '-h' || -z "$arg1" ]]; then
echo "Leaves the output of addresses.bash on a remote host. key ssh authentication prefered for automation"
echo "Usage: $0 \$ targetHost"
exit 0
fi
#exit when command fails (use || true when a command can fail)
set -o errexit
#exit when your script tries to use undeclared variables
set -o nounset
# in scripts to catch mysqldump fails
set -o pipefail
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Dir of the script
__root="$(cd "$(dirname "${__dir}")" && pwd)" # Dir of the dir of the script
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" # Full path of the script
__base="$(basename ${__file})" # Name of the script
ts=`date +'%Y%m%d-%H%M%S'`
ds=`date +'%Y%m%d'`
pid=`ps -ef | grep ${__base} | grep -v 'vi ' | head -n1 | awk ' {print $2;} '`
formerDir=`pwd`
# If you require named arguments, see
# http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
export DISPLAY=:0
echo Begin `date` .....
echo; echo; echo;
### BEGIN SCRIPT ###############################################################
#(a.k.a set -x) to trace what gets executed
set -o xtrace
#if ! which addresses.bash ; then
# echo "addresses.bash is required"
# exit 1
#fi
scratchFile=/tmp/`hostname`IsAt.txt
~/bin/addresses.bash > $scratchFile
chmod 600 $scratchFile
targetHost=$1
scp $scratchFile $targetHost:~/
set +x
### END SCIPT ##################################################################
cd $formerDir