12345678910111213141516171819202122 |
- #!/bin/sh
- cd "$(dirname "$0")"
- . ./.env
- . venv/bin/activate
- trap 'echo "Caught Ctrl-C"' INT
- while [ 1 ] ; do
- LOGFILE=log-$(date +%Y%m%d-%H%M%S).txt
- python doctor.py|tee logs/$LOGFILE
- # We expect at least
- # * '<Enter>' in the header
- # * first '>' prompt
- # A third '>' means at least a single prompt from the user
- if [ $(grep -c '>' logs/$LOGFILE) -lt 3 ] ; then
- rm logs/$LOGFILE
- dialog --title "Session aborted" --msgbox "Hit <Enter> to continue..." 5 60
- else
- # clear aborted logs that somehow weren't caught
- grep -c ">" logs/*.txt | grep ':[12]$'| sed 's/:.*//' | xargs rm
- python genlogs.py
- dialog --title "Session saved" --msgbox "Session saved to file $LOGFILE" 5 60
- fi
- done
|