forked from shaunhogan/gui-step1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uploadIgloo.sh
59 lines (46 loc) · 1.56 KB
/
uploadIgloo.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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/bash
# uploadIgloo.sh
# script to run on Windows machine (hcaldaq-pc)
# 1. copy json file to Linux machine (cmshcal11)
# 2. upload results to database
###################################################
# Set Initial Data #
###################################################
echo "Setting initial data"
# use explicit ip address because Windows machine does not resolve host aliases
remoteDatabase=/home/django/testing_database_hb
remoteJson=$remoteDatabase/uploader/temp_json
remoteScript=$remoteDatabase/uploader/step123.sh
jsonLoc=temp_json
jsonTag=step3_raw.json
echo "Initial data set"
echo ""
# Note: $? is the error code of the last command executed
# Use $? to check if the last command was successful
echo " Copying json file to $remoteHost"
# 1. copy json file to Linux machine (cmshcal11)
scp $jsonLoc/*$jsonTag $remoteHost:$remoteJson
if [ $? -eq 0 ]
then
echo " Successfully copied json file to $remoteHost"
else
echo " ERROR: Failed to copy json file to $remoteHost"
echo "ERROR: No information uploaded to database"
exit 1
fi
# remote json files if copying was successful
rm $jsonLoc/*$jsonTag
# 2. upload results to database
# include option -w for no color ($1)
ssh $remoteHost $remoteScript $1
if [ $? -eq 0 ]
then
echo " Successfully uploaded results to database"
else
echo " ERROR: Failed to upload results to database"
echo "ERROR: No information uploaded to database"
exit 1
fi
echo "Successfully uploaded results to database"
echo "Finished"