-
Notifications
You must be signed in to change notification settings - Fork 1
/
its
executable file
·71 lines (60 loc) · 1.53 KB
/
its
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
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
CURRPATH=$(pwd)
SOURCE=$0
# We need to resolve the path to the actual code directory (Running executable
# could be a symlink).
while [ -h "$SOURCE" ]; do
BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$BASEDIR/$SOURCE"
done
BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
PYTHONCMD="${PYTHON:-python} -B"
abspath(){
cd "$(dirname "$1")"
printf "%s/%s\n" "$(pwd)" "$(basename "$1")"
}
echo $BASEDIR
# Flags
#
# v verbose
# i input file
# o output file
# c code file
# e cmd file
input=stdin
output=stdout
code=$BASEDIR/assets/code.c
cmd=stderr
vLevel=0
iFlag=0
oFlag=0
while getopts vi:o:c:e: myVar; do
case $myVar in
v) vLevel=$((vLevel+1))
;;
i) input=$(abspath $OPTARG)
iFlag=1
;;
o) output=$(abspath $OPTARG)
oFlag=1
;;
c) code=$(abspath $OPTARG)
;;
e) cmd=$(abspath $OPTARG)
;;
esac
done
echo Code is : $code
echo Verbosity is : $vLevel
echo Input file is : $input
echo Output file is : $output
echo Command file is : $cmd
export PYTHONPATH="$PYTHONPATH:$BASEDIR/external/ply"
export PYTHONPATH="$PYTHONPATH:$BASEDIR/external/pcpp"
export PYTHONPATH="$PYTHONPATH:$BASEDIR/external/six"
# Now the python script would be run with the given arguments
EXECUTE_SCRIPT=$PYTHONCMD" ""$BASEDIR""/main.py "
EXECUTE_SCRIPT=$EXECUTE_SCRIPT"$code $vLevel $input $output $cmd"
echo $EXECUTE_SCRIPT
$EXECUTE_SCRIPT