-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.sh
More file actions
28 lines (21 loc) · 699 Bytes
/
python.sh
File metadata and controls
28 lines (21 loc) · 699 Bytes
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
#!/bin/bash
INPUT_REQUIRED=false
# Check for the flag (modify if using a different flag name)
if [[ "$1" == "inputtrue" ]]; then
INPUT_REQUIRED=true
shift # Remove the flag from the argument list
fi
# Run the Python code with input redirection (if required)
if [[ $INPUT_REQUIRED == true ]]; then
# Check if input file exists (modify if needed)
python3 /usr/src/app/python-engine/app/main.py < /usr/src/app/python-engine/app/input.txt > output.txt 2> runtime_error.txt
else
python3 /usr/src/app/python-engine/app/main.py > output.txt 2> runtime_error.txt
fi
# Check for runtime errors
if [ $? -ne 0 ]; then
echo "Runtime error!"
cat runtime_error.txt
exit 1
fi
cat output.txt