CCCPaste

BASH Dialog Shift Log example #1

#!/bin/bash
###################################################################### 
#Copyright (C) 2023  Kris Occhipinti
#https://filmsbykris.com

#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation version 3 of the License.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see .
###################################################################### 

tmpfile="/tmp/shiftlog.tmp"
logfile="/tmp/shiftlog"
backtitle="Cool Fire Department"

exec 3>&1;
user="$(dialog --backtitle "$backtitle" --inputbox "Enter the name" 15 30 2>&1 1>&3)"
[[ "$user" ]] || exit

date="$(dialog --backtitle "$backtitle" --calendar 'calendar'  5 50 2>&1 1>&3)"
echo $date
[[ "$date" ]] || exit


#dialog --title "Shift Log" --backtitle "$backtitle" --editbox "$logfile" 16 50 2> "$tmpfile"; cp "$tmpfile" "$logfile"
dialog --title "Shift Log" --backtitle "$backtitle" --editbox "$logfile" 16 50 2> "$tmpfile"; cp "$tmpfile" "$logfile"

clear
echo "$user -- $date"
cat $logfile