I have created a menu script I have created to update a monitoring screen that is viewed in another office by a team, but I am sure this script can be improved on, as it is a little messy, and I can not get it to correctly exit out if a function is called on and then and incorrect keystroke is pressed, so I have just got the script to exit totally if an incorrect key press is made from an option.
What I have to update is a line like this one:-
allitemsData[0]="|green|1107 - Monitoring of Allitems Loads starts at 1915|"
the 1st part can change and be called cgcData[0] or something of the like, as there are 8 different areas that have to be updated.
Here is the unix shell script below.
#!/bin/ksh
# set system variables
timeNow=$(date +"%H%M"
monitor=/tmp/changemonitor.$$
monitor1=/tmp/changemonitor1.$$
monitor2=/tmp/changemonitor2.$$
monitor3=/tmp/changemonitor3.$$
monitor4=/tmp/changemonitor4.$$
monitor5=/tmp/changemonitor5.$$
workdir=/opt/contents/PEGASYSTEMS/JSCRIPT
# Start of functions
function monitornew
{
cat $jsfile >> $logfile
cat $jsfile > $monitor
cat $monitor | tr -s '|' ' ' > $monitor1
cat $monitor1 | awk '{print $1,$2}' > $monitor
echo ""
echo ""
cat $monitor | awk '{print $2}' > $monitor1
cat $monitor | awk '{print $1}' > $monitor2
tr = '\t' < $monitor2 | awk '{print $1}' > $monitor
cat $monitor > $monitor3
tr Data[0] '\t' < $monitor3 | awk '{print $1}' > $monitor4
cat $jsfile > $monitor3
cat $monitor3 | cut -d '|' -f3 > $monitor5
monitor1=$(more $monitor1)
monitor=$(more $monitor)
monitor4=$(more $monitor4)
monitor5=$(more $monitor5)
echo "\\t The colour status of the monitoring screen $monitor4 at the moment is $monitor1 "
echo "\\t The last timestamp and message is $monitor5 "
echo ""
echo "\\t Please select an option you wish to change the monitor screen colour to ..."
echo "\\t \\t r - red"
echo "\\t \\t a - amber"
echo "\\t \\t g - green"
echo "\\t \\t q - quit"
echo ""
echo "\\t Type your option here: \\c"
read colour
case $colour in
r) colour=red ;;
a) colour=amber ;;
g) colour=green ;;
q) echo ""; echo "\\t \\t Quitting the update monitoring screen menu program ...." ; echo "" ; exit 0;;
*) echo \\t \\t \\t \\t That was not a valid option; exit 0;;
esac
echo ""
echo "\\t Please type in the popup message you wish to appear when clicked"
echo ""
echo "\\t Type your message here: \\c"
read popup
echo ""
echo "\\t The monitoring screen has now changed the following information is now being displayed ..."
echo ""
echo "\\t The screen is now $colour and has the message $popup time stamped at $timeNow"
echo "$monitor=\"|$colour|$timeNow - $popup|\"" > $jsfile
echo ""
echo "\\t Hit Return to go back to the main menu"
read
rm /tmp/changemonitor*
}
# End of functions
# Main Menu
clear
echo "\\t \\t a - Update the Allitems Screen"
echo "\\t \\t b - Update the Dishonour Screen"
echo "\\t \\t c - Update the Bulkstore Screen"
echo "\\t \\t d - Update the Exceptions Screen"
echo "\\t \\t e - Update the CGC Screen"
echo "\\t \\t f - Update the Verifications Screen"
echo "\\t \\t g - Update the Conformation File Screen"
echo "\\t \\t h - Update the Verifications Failure File Screen"
echo "\\t \\t i - About This Pega Tool"
echo "\\t \\t q - Quit"
echo ""
echo "\\t \\t Select an option \\c"
read ans
clear
case $ans in
a) jsfile=$workdir/monitorAllitems.js
logfile=$workdir/monitorAllitems.log
monitornew
$0;;
b) jsfile=$workdir/monitorDishonour.js
logfile=$workdir/monitorDishonour.log
monitornew
$0;;
c) jsfile=$workdir/monitorBulkstore.js
logfile=$workdir/monitorBulkstore.log
monitornew
$0;;
d) jsfile=$workdir/monitorExceptions.js
logfile=$workdir/monitorExceptions.log
monitornew
$0;;
e) jsfile=$workdir/monitorCGC.js
logfile=$workdir/monitorCGC.log
monitornew
$0;;
f) jsfile=$workdir/monitorVerifications.js
logfile=$workdir/monitorVerifications.log
monitornew
$0;;
g) jsfile=$workdir/monitorConfirmation.js
logfile=$workdir/monitorConfirmation.log
monitornew
$0;;
h) jsfile=$workdir/monitorVfail.js
logfile=$workdir/monitorVfail.log
monitornew
$0;;
q) echo ""; echo "\\t \\t Quitting the update monitoring screen menu program ...." ; echo "" ; exit 0;;
*) echo \\t \\t \\t \\t That was not a valid option; $0;;
esac
Does anyone have any ideas??
Regards
Ian
What I have to update is a line like this one:-
allitemsData[0]="|green|1107 - Monitoring of Allitems Loads starts at 1915|"
the 1st part can change and be called cgcData[0] or something of the like, as there are 8 different areas that have to be updated.
Here is the unix shell script below.
#!/bin/ksh
# set system variables
timeNow=$(date +"%H%M"
monitor=/tmp/changemonitor.$$
monitor1=/tmp/changemonitor1.$$
monitor2=/tmp/changemonitor2.$$
monitor3=/tmp/changemonitor3.$$
monitor4=/tmp/changemonitor4.$$
monitor5=/tmp/changemonitor5.$$
workdir=/opt/contents/PEGASYSTEMS/JSCRIPT
# Start of functions
function monitornew
{
cat $jsfile >> $logfile
cat $jsfile > $monitor
cat $monitor | tr -s '|' ' ' > $monitor1
cat $monitor1 | awk '{print $1,$2}' > $monitor
echo ""
echo ""
cat $monitor | awk '{print $2}' > $monitor1
cat $monitor | awk '{print $1}' > $monitor2
tr = '\t' < $monitor2 | awk '{print $1}' > $monitor
cat $monitor > $monitor3
tr Data[0] '\t' < $monitor3 | awk '{print $1}' > $monitor4
cat $jsfile > $monitor3
cat $monitor3 | cut -d '|' -f3 > $monitor5
monitor1=$(more $monitor1)
monitor=$(more $monitor)
monitor4=$(more $monitor4)
monitor5=$(more $monitor5)
echo "\\t The colour status of the monitoring screen $monitor4 at the moment is $monitor1 "
echo "\\t The last timestamp and message is $monitor5 "
echo ""
echo "\\t Please select an option you wish to change the monitor screen colour to ..."
echo "\\t \\t r - red"
echo "\\t \\t a - amber"
echo "\\t \\t g - green"
echo "\\t \\t q - quit"
echo ""
echo "\\t Type your option here: \\c"
read colour
case $colour in
r) colour=red ;;
a) colour=amber ;;
g) colour=green ;;
q) echo ""; echo "\\t \\t Quitting the update monitoring screen menu program ...." ; echo "" ; exit 0;;
*) echo \\t \\t \\t \\t That was not a valid option; exit 0;;
esac
echo ""
echo "\\t Please type in the popup message you wish to appear when clicked"
echo ""
echo "\\t Type your message here: \\c"
read popup
echo ""
echo "\\t The monitoring screen has now changed the following information is now being displayed ..."
echo ""
echo "\\t The screen is now $colour and has the message $popup time stamped at $timeNow"
echo "$monitor=\"|$colour|$timeNow - $popup|\"" > $jsfile
echo ""
echo "\\t Hit Return to go back to the main menu"
read
rm /tmp/changemonitor*
}
# End of functions
# Main Menu
clear
echo "\\t \\t a - Update the Allitems Screen"
echo "\\t \\t b - Update the Dishonour Screen"
echo "\\t \\t c - Update the Bulkstore Screen"
echo "\\t \\t d - Update the Exceptions Screen"
echo "\\t \\t e - Update the CGC Screen"
echo "\\t \\t f - Update the Verifications Screen"
echo "\\t \\t g - Update the Conformation File Screen"
echo "\\t \\t h - Update the Verifications Failure File Screen"
echo "\\t \\t i - About This Pega Tool"
echo "\\t \\t q - Quit"
echo ""
echo "\\t \\t Select an option \\c"
read ans
clear
case $ans in
a) jsfile=$workdir/monitorAllitems.js
logfile=$workdir/monitorAllitems.log
monitornew
$0;;
b) jsfile=$workdir/monitorDishonour.js
logfile=$workdir/monitorDishonour.log
monitornew
$0;;
c) jsfile=$workdir/monitorBulkstore.js
logfile=$workdir/monitorBulkstore.log
monitornew
$0;;
d) jsfile=$workdir/monitorExceptions.js
logfile=$workdir/monitorExceptions.log
monitornew
$0;;
e) jsfile=$workdir/monitorCGC.js
logfile=$workdir/monitorCGC.log
monitornew
$0;;
f) jsfile=$workdir/monitorVerifications.js
logfile=$workdir/monitorVerifications.log
monitornew
$0;;
g) jsfile=$workdir/monitorConfirmation.js
logfile=$workdir/monitorConfirmation.log
monitornew
$0;;
h) jsfile=$workdir/monitorVfail.js
logfile=$workdir/monitorVfail.log
monitornew
$0;;
q) echo ""; echo "\\t \\t Quitting the update monitoring screen menu program ...." ; echo "" ; exit 0;;
*) echo \\t \\t \\t \\t That was not a valid option; $0;;
esac
Does anyone have any ideas??
Regards
Ian