OpenMTC/doc/example-apps/start-simple-app

36 lines
849 B
Plaintext
Raw Normal View History

2017-11-07 13:41:38 +00:00
#!/usr/bin/env bash
base_path=$(dirname "$(readlink -f "${0}")")
################################################################################
# set app_file
declare -a app_array
app_array=($(find ${base_path} -name "*.py"))
array_length=${#app_array[@]}
# print possibilities
for i in $(seq 1 ${array_length}); do
path=${app_array[$[${i}-1]]}
echo "[${i}] $(basename ${path})"
done
# read choice
while true; do
read -n 2 -p "Choose the app to start: " choice
[[ ${choice} =~ ^[0-9]+$ ]] && \
[ ${choice} -gt 0 -a ${choice} -le ${array_length} ] && \
echo && break
echo " Wrong choice. Do it again."
done
app_file=${app_array[$[${choice}-1]]}
################################################################################
# run app_file
cd ${base_path}
. ../../common/prep-env.sh
python ${app_file}