New Setup programs

I worked a little bit on the bash setup programs that I had posted before. I am going to post 2 new versions today. The first is the one I use; it is a little more general. The second one is for my friend/host who has more specific scientific/sheepdog goals. Feel free to try either one out. They still need debugging, and backup still doesn’t work. Would appreciate feedback on bugs. The first program is setup10.sh, and is launched, creating a log file from supersetup10.sh. You need both files in your bin directory of a linux distribution if you want a log file. For the more professional version, the program is profsetup.sh, and is launched, creating a log file from superprofsetup.sh.

So, here are the programs:
setup10.sh
#!/bin/bash
#
#
#
#
#
#
function neworder {
echo “Please take a few minutes to identify urgent matters that can be solved today.”
read urgent
echo $urgent “is urgent and can be solved today.”
echo ” ”
echo “Please take a few minutes to identify urgent matters that will require more time.”
read urgentneedingtime
echo $urgentneedingtime “is urgent and needs priority time over the next few days.”
echo ” ”
echo ” ”
echo “Please enter numbers in the order you would like to proceed separated”
echo “by spaces. Simply enter 0 to ignore. Enter r at anytime in the describe activity space to redefine order of day. Enter e at anytime in the describe activity space to exit gracefully and end program.”
echo ” ”
echo ” ”
echo ” ”
local i=1
while [ $i -lt $num_events ]
do
echo “$i. ${event_array[$i]}.”
i=$(( $i + 1 ))
done
echo ” ”
echo ” ”
echo “Choices?”
read choice
echo ” ”
echo “You chose to proceed in the following order: $choice”
echo ” ”
echo ” ”
for i in ${choice}
do
echo “${event_array[$i]}”
done
return
}
#
#
function execute_events {
count=””
for i in ${choice}
do
finished=””
eventbgn=””
description=””
echo ” ”
echo ” ”
echo “${event_array[$i]]} anticipated.”
echo “Describe your activity. ”
read description
case “$description” in
r)
echo “Time to redefine your day. The old order was:”
for j in ${choice}
do
echo “${event_array[$j]}”
done
neworder
echo ” ”
echo ” ”
for j in ${choice}
do
echo “${event_array[$j]}”
done
finished=”not”
echo “Program is continuing with a new order.”
break
;;
e)
echo “Ending gracefully. Bye.”
break 10
;;
esac

echo “Please press enter when you begin to ${event_array[$i]}.”
read bgn
date
# eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
# expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
# echo $eventbgn
echo “Please press enter when you have finished to ${event_array[$i]]}.”
read finished
while [ -n “$finished” ];
do
break
done
date

eventend=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
echo
echo “You spent $(($((eventend))-$((eventbgn)))) minutes to $description ”
echo “thereby accomplishing your ${event_array[$i]]} activity.”
echo “Comments on success in achieving goal?”
read goalmet
echo $goalmet
count=$(expr $((count+1)))
echo -n $count “. ”
case “$i” in
0)
echo “It’s ok. We all have bad days.”
;;
1)
echo “Your family says “I love you” and doesn’t feel taken for granted.”
;;
2)
echo “Dog Walk done. Your dogs say: “I love you””.
;;
3)
echo “Work done. Relax.”
;;
4)
echo “Work out done. Your body says thank you for caring!”
;;
5)
echo “Clean up done. Good job!!!!!”
;;
6)
echo “Pay bills done. Ouch!”
;;
7)
echo “The world embraces you! Thank you for doing your part to care for her.”
;;
8 )
echo “The date and time of your last successful backup was:”
echo “Your currently available and used file space is:”
df
echo “Would you like to extract the files of your last backup to see what they were and/or compare them with your current file system? (y or n)”
read answer
if [ $answer == “y” ]
then
echo “The default for the backup iso is /backup/oldbackup/backup.iso . ”
if [ -e /backup/oldbackup/backup.iso ]
then
echo “Backup file exists in /backup/oldbackup/backup.iso”
du /backup/oldbackup/backup.iso
echo “You will need x diskspace to extract the old files.”
# check to see if space exists
tar -xvf /backup/oldbackup/backup.iso
else
echo “Backup file is not mounted in defined location or does not exist.”
echo “Current files in backup directory are:”
ls -tal /backup/oldbackup
echo “Would you like to extract one of these files? (y or n)”
read answer
if [ $answer == “y” ]
then
echo “Which file?”
read fname
# check to see if enough space exists then
tar -xvf /backup/oldbackup/$fname
fi
fi
else
echo “Ok. We’ll stop here.”
fi
# if ( “$answer” “n” )
# then
# isoname=”/backup/oldbackup/backup.iso”
# echo “Input old iso name (with dir), press enter to use default (” $isoname “):”
# read isoname
# if ( -e $isoname)
# then
# tar -xvf $isoname
#
# fi
# fi
echo “Would you like to see a list of files that were “touched” since your last backup or would you prefer a more comprehensive file comparison?”
echo “Interactively select each file for shredding or backup?”
echo “Schedule backup or proceed immediately.”
echo “Schedule shredding or proceed immediately.”
echo “Last chance to say no if you are doing this immediately.”
echo “Backup system activity done. Find a blank CD.”
;;
esac
done
finished=”done”
return
}
description = “”
event_array=(“nothing” “family time” “walking dogs” “work” “workout” “clean up” “pay bills” “world peace or mother earth work” “computer work”)
num_events=9
date
echo “Today is a brand new day. How would you like to start?”
echo ” ”
choice=(1 2 3 4 5 6 7 8 )
neworder
execute_events
# while [ -n $finished -o $description == “r” ];
while [ “$description” == “r” ]
do
case “$description” in
r)
echo “Working on events.”
execute_events
;;
esac
done
if [ “$description” != “e” ]
then
echo “Program completed. Goals for the day achieved. VERY WELL DONE.”
fi

#
#
#
#

supersetup10.sh

#!/bin/bash
setup10.sh | tee setup10.out
grep “urgent” setup10.out > supersetup10.log
grep “You spent” setup10.out >> supersetup10.log
#

profsetup.sh
#!/bin/bash
#
#
#
#
#
#
function neworder {
echo “Please take a few minutes to identify urgent matters that can be solved today.”
read urgent
echo $urgent “is urgent and can be solved today.”
echo ” ”
echo “Please take a few minutes to identify urgent matters that will require more time.”
read urgentneedingtime
echo $urgentneedingtime “is urgent and needs priority time over the next few days.”
echo ” ”
echo ” ”
echo “Please enter numbers in the order you would like to proceed separated”
echo “by spaces. Simply enter 0 to ignore. Enter r at anytime in the describe activity space to redefine order of day. Enter e at anytime in the describe activity space to exit gracefully and end program.”
echo ” ”
echo ” ”
echo ” ”
local i=1
while [ $i -lt $num_events ]
do
echo “$i. ${event_array[$i]}.”
i=$(( $i + 1 ))
done
echo ” ”
echo ” ”
echo “Choices?”
read choice
echo ” ”
echo “You chose to proceed in the following order: $choice”
echo ” ”
echo ” ”
for i in ${choice}
do
echo “${event_array[$i]}”
done
return
}
#
#
function execute_events {
count=””
for i in ${choice}
do
finished=””
eventbgn=””
description=””
echo ” ”
echo ” ”
echo “${event_array[$i]]} anticipated.”
case $i in
3)
echo “Briefly state the disease that this activity will contribute to helping to cure.”
read disease
echo “Persons with” $disease ” may be helped by this activity.”
echo “Please choose from the following activities that may be anticipated:”
echo “a) reading a paper.”
echo “b) writing a paper.”
echo “c) doing an experiment.”
echo “d) discussion of results.”
echo “e) preparing a talk.”
echo “f) solving administrative problems.”
echo “g) solving lab equipment problems.”
echo “h) other.”
read labchoice
echo “You chose to do” $labchoice “.”
;;
esac
echo “Describe your activity. ”
read description
case “$description” in
r)
echo “Time to redefine your day. The old order was:”
for j in ${choice}
do
echo “${event_array[$j]}”
done
neworder
echo ” ”
echo ” ”
for j in ${choice}
do
echo “${event_array[$j]}”
done
finished=”not”
echo “Program is continuing with a new order.”
break
;;
e)
echo “Ending gracefully. Bye.”
break 10
;;
esac

echo “Please press enter when you begin to ${event_array[$i]}.”
read bgn
date
# eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
# expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
# echo $eventbgn
echo “Please press enter when you have finished to ${event_array[$i]]}.”
read finished
while [ -n “$finished” ];
do
break
done
date

eventend=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+
expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”
echo
echo “You spent $(($((eventend))-$((eventbgn)))) minutes to $description ”
echo “thereby accomplishing your ${event_array[$i]]} activity.”
echo “Comments on success in achieving goal?”
read goalmet
echo $goalmet
count=$(expr $((count+1)))
echo -n $count “. ”
case “$i” in
0)
echo “It’s ok. We all have bad days.”
;;
1)
echo “Big hug. Your family and friends are happy to have a little of your time.”
;;
2)
echo “Dog work done. Your dogs say: “I love you””.
;;
3 | 4)
echo “Work done. Take a short break, regroup, and tackle again or ifyou were successful, pat on the back, and prepare to tackle new job.”
;;
5)
echo “Work out done. Your body says thank you for caring!”
;;
6)
echo “Clean up done. Good job!!!!!”
;;
7)
echo “Pay bills done. Ouch!”
;;
8 )
echo “The world embraces you! Thank you for doing your part to care for her.”
;;
9)
echo “The date and time of your last successful backup was:”
echo “Your currently available and used file space is:”
df
echo “Would you like to extract the files of your last backup to see what they were and/or compare them with your current file system? (y or n)”
read answer
if [ $answer == “y” ]
then
echo “The default for the backup iso is /backup/oldbackup/backup.iso . ”
if [ -e /backup/oldbackup/backup.iso ]
then
echo “Backup file exists in /backup/oldbackup/backup.iso”
du /backup/oldbackup/backup.iso
echo “You will need x diskspace to extract the old files.”
# check to see if space exists
tar -xvf /backup/oldbackup/backup.iso
else
echo “Backup file is not mounted in defined location or does not exist.”
echo “Current files in backup directory are:”
ls -tal /backup/oldbackup
echo “Would you like to extract one of these files? (y or n)”
read answer
if [ $answer == “y” ]
then
echo “Which file?”
read fname
# check to see if enough space exists then
tar -xvf /backup/oldbackup/$fname
fi
fi
else
echo “Ok. We’ll stop here.”
fi
# if ( “$answer” “n” )
# then
# isoname=”/backup/oldbackup/backup.iso”
# echo “Input old iso name (with dir), press enter to use default (” $isoname “):”
# read isoname
# if ( -e $isoname)
# then
# tar -xvf $isoname
#
# fi
# fi
echo “Would you like to see a list of files that were “touched” since your last backup or would you prefer a more comprehensive file comparison?”
echo “Interactively select each file for shredding or backup?”
echo “Schedule backup or proceed immediately.”
echo “Schedule shredding or proceed immediately.”
echo “Last chance to say no if you are doing this immediately.”
echo “Backup system activity done. Find a blank CD.”
;;
esac
done
finished=”done”
return
}
description = “”
event_array=(“nothing” “family/friends time” “dog walk and/or training – sheep dog trial” “lab work” “farm work” “workout” “clean up” “pay bills” “world peace or mother earth work” “computer work”)
num_events=10
date
echo “Today is a brand new day. How would you like to start?”
echo ” ”
choice=(1 2 3 4 5 6 7 8 9)
neworder
execute_events
# while [ -n $finished -o $description == “r” ];
while [ “$description” == “r” ]
do
case “$description” in
r)
echo “Working on events.”
execute_events
;;
esac
done
if [ “$description” != “e” ]
then
echo “Program completed. Goals for the day achieved. VERY WELL DONE.”
fi
#
#
#
#

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s