generated from AEADataEditor/replication-template-development
-
Notifications
You must be signed in to change notification settings - Fork 5
/
run.sh
executable file
·63 lines (48 loc) · 1.11 KB
/
run.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
58
59
60
61
62
63
#!/bin/bash
#set -ev
# Get some functions
. ./tools/parse_yaml.sh
# read parameters
eval $(parse_yaml config.yml)
project="${openicpsr:-$dataverse}"
project="${project:-$zenodo}"
project="${project:-$osf}"
main="${main:-main.do}"
statabin="${statabin:-stata-mp}"
rbin="${rbin:-R}"
maindir="$(dirname "$main")"
if [[ "$maindir" == "." ]]
then
# we don't have a path
fullmain="$(find $project -name $main)"
maindir="$(dirname "$fullmain")"
fi
ext=$(echo $main | awk -F. ' { print $2 } ')
echo "Active project: $project"
echo "Configured main file: $main"
echo "Configured subdir: $maindir"
echo "Identified extension: $ext"
# go into the project directory
set -ev
# show all the files
find $project -type f
# now go to where the main file is
cd "$maindir"
case $ext in
do)
if [[ -z $(which $statabin 2>/dev/null || echo "" ) ]]
then
echo "Stata not found - skipping"
exit 0
fi
$statabin -b do "$main"
;;
R|r)
if [[ -z $(which $rbin 2>/dev/null || echo "" ) ]]
then
echo "R not found - skipping"
exit 0
fi
$rbin CMD BATCH "$main"
;;
esac