 | Junior Member with 2 posts. | | Join Date: Mar 2007 Experience: Intermediate | | Bash week and input help Hi all,
I am hopeful that someone will be able to help me out here.
I am writing a small bash script to rotate a schedule on a monthly, 3 weekly, and week schedule between multiple tasks and with 3 employees. I have manually entered the schedule (52 entries) because I can't think of the math to do it otherwise. I would love a better way to do it, so if anyone has any suggestions that would be great.
I do have two questions that I hope someone could help with.
1. Is there anyway to figure out a date or range of dates if all one know is the week number (yearly week that is 1-52) I currently use the date function to find the appropriate week number but I can't seem to go in the reverse.
2. I am currently suggesting a week number based on the date %V functoin and adding one to it to suggest next weeks week number (week=week+1). The problem I am having is, I can suggest the week and read the variable (pickweek) but I can't let the user just hit enter and capture the suggested week number. The user has to enter it manually. Anyone know how to suggest it based on the date function and then if the user hits enter, accpted that value, or else use the user supplied week.
Any help is appreicated.
Thank you,
mortis... | | Distinguished Member with 14,984 posts. | | Join Date: Sep 2003 Location: -71.45091, 42.27841 | | Quote: |
Originally Posted by bashboy Hi all,
I am hopeful that someone will be able to help me out here.
I am writing a small bash script to rotate a schedule on a monthly, 3 weekly, and week schedule between multiple tasks and with 3 employees. I have manually entered the schedule (52 entries) because I can't think of the math to do it otherwise. I would love a better way to do it, so if anyone has any suggestions that would be great.
I do have two questions that I hope someone could help with.
1. Is there anyway to figure out a date or range of dates if all one know is the week number (yearly week that is 1-52) I currently use the date function to find the appropriate week number but I can't seem to go in the reverse.
2. I am currently suggesting a week number based on the date %V functoin and adding one to it to suggest next weeks week number (week=week+1). The problem I am having is, I can suggest the week and read the variable (pickweek) but I can't let the user just hit enter and capture the suggested week number. The user has to enter it manually. Anyone know how to suggest it based on the date function and then if the user hits enter, accpted that value, or else use the user supplied week.
Any help is appreicated.
Thank you,
mortis... | Hi bashboy,
Welcome to TSG!
How many multiple tasks for the three employees are you trying to schedule? Is each employee capable of doing all of the tasks? Is your schedule shift related?
What tasks are related to monthly, 3-weekly, or weekly - all tasks, some tasks, or just one task for each category?
Zeller's algorithm computes the day of the week for any calendar date, but that doesn't appear to apply to what you want to do.
Does your current schedule look like? Assumes 1 task/category:
weekofyear weekly task 3-weekly task monthly task
1 employeeA employeeB employeeC
2 employeeC employeeA employeeB
,,,
What is the current layout of your schedule as you have it. Just looking for a pattern, so reply using abstraction of real data, i.e. no names, etc.
How do you want to rotate the schedule between employees and multiple tasks per category: monthly, 3-weekly, weekly?
-- Tom
__________________ The independence created by philosophical insight is - in my opinion - the mark of distinction
between a mere artisan or specialist and a real seeker after truth. - Einstein 1944
Imagination is more important than knowledge. - Einstein | | Junior Member with 2 posts. | | Join Date: Mar 2007 Experience: Intermediate | | Sorry lotuseclat79,
Had a busy week.
This is what I have so far (it has been sanitized).
Thank you,
Bashboy
--------------------------------------------------------------------------
#!/bin/bash
clear
echo
echo
echo "Today's date is `date +%m-%d-%Y`, this is week `date +"%V"`."
export today=`date +%m-%d-%Y`
export week=`date +%V`
let week=week+1
echo
echo -n "Please enter the week number that you would like to use [$week]: ";
read pickweek
echo
echo
person1="person1"
person2="person2"
person3="person3"
hot="Hot"
pc="pc"
rep=" Rep"
block4="Hot
pc
Rep"
block5="Coordinator
Holiday"
if [ $pickweek = 1 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 2 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 3 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 4 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 5 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 6 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 7 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k1="$block5"
else
if [ $pickweek = 8 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 9 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 10 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 11 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 12 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 13 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 14 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 15 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 16 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 17 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 18 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 19 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 20 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 21 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 22 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 23 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 24 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 25 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 26 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 27 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 28 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 29 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 30 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 31 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 32 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 33 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 34 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 35 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 36 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 37 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 38 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 39 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 40 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 41 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 42 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 43 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 44 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 45 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 46 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 47 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 48 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k4="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 49 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 50 ]; then
bperson1k1="$person2"
bperson1k2="$person1"
bperson1k3="$person2"
bperson1k5="$block4"
bperson1k8="$block5"
else
if [ $pickweek = 51 ]; then
bperson1k1="$person1"
bperson1k2="$person2"
bperson1k3="$person2"
bperson1k6="$block4"
bperson1k7="$block5"
else
if [ $pickweek = 52 ]; then
bperson1k1="$person2"
bperson1k2="$person2"
bperson1k3="$person1"
bperson1k6="$block4"
bperson1k8="$block5"
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
output="This is the rotating schedule week $pickweek (`date -d "+3 day" +%x` - `date -d "+7 day" +%x`)
$bperson1k1
------------------------
Reports
Read Lists
Digest
Statistics
Coordination
$bperson1k4
$bperson1k7
$bperson1k2
------------------------
Triage
Monitor
Schedule
Email
Maintenperson1ce
Tips
Coordination
$bperson1k5
$bperson1k8
$bperson1k3
------------------------
Activity
Report
Call
Superson2aries
Website
Coordination
$bperson1k6
$bperson1k9"
echo "$output"
echo
echo -n "Would you like to publish this schedule? [Y,n]";
read -e pub
if [ "$pub" = "n" ]; then
echo "Have a nice day!"
exit
else
if [ "$pub" = "y" ]; then
echo "Sending this schedule to"
echo "email"
echo "email"
echo "email"
echo "email"
echo "email"
echo "$output" | mail email -s "Rotating Schedule - calendar week $pickweek (`date -d "+3 day" +%x` - `date -d "+7 day" +%x`)"
fi
fi
---------------------------------------------------------------------------------------
So, some of the schedules change /week, some /month.
Thanks again... | | Distinguished Member with 14,984 posts. | | Join Date: Sep 2003 Location: -71.45091, 42.27841 | | Hi bashboy,
There is a pattern in your assignments as follows:
if week mod 3 == 0 then assign pattern 3
else if week mod 3 == 2 then assign pattern 2
else if week mod 3 == 1 then assign pattern 1
where mod is the remainder of week/n (n=3)
Note: I think the mod operator in script is the % operator.
and pattern 1 is given by the string 22145
and pattern 2 is given by the string 21245
and pattern 3 is given by the string 12245
Your schedule has 7 different pairs of the numbers
(5,7) (6,7) (4,7) (4,8) (5,1) ((6,8) (5,8)
for assigning variations in the tasks for bpersonlkn where n is not = 1 or 2 or 3
The anomaly is (5,1) which only appears once in your schedule. I assume that is for some reason occuring in week 7.
I did not find any repeating pattern for these, but aside from the anomaly, the other 6 pairs were evenly divided between 3 pairs with 8 weeks, and 3 pairs with 9 weeks + the anomaly = 52 weeks.
In order to simplfy the schedule, you would need to think of a way to repeat a pattern for the last two tasks in each weeks schedule - which are always assigned $block4 and $block5 or the 45 of each pattern string I talked about above.
This has been a first cut analysis at simplifying the schedule.
I'll go back and look at your original question sometime this weekend to see if there is a way to do it.
I see the opportunity to greatly simplify your scheduling by revising the script to compute the output instead of enumerating each weeks tasks - if you can come up with a reasonable proposal to make a repeating pattern for last two tasks as I mentioned above. I don't know whether that is possible or even recommended - you decide.
-- Tom
__________________ The independence created by philosophical insight is - in my opinion - the mark of distinction
between a mere artisan or specialist and a real seeker after truth. - Einstein 1944
Imagination is more important than knowledge. - Einstein
Last edited by lotuseclat79 : 07-Apr-2007 07:47 AM.
| | Distinguished Member with 14,984 posts. | | Join Date: Sep 2003 Location: -71.45091, 42.27841 | | Quote: |
Originally Posted by bashboy Hi all,
I am hopeful that someone will be able to help me out here.
I am writing a small bash script to rotate a schedule on a monthly, 3 weekly, and week schedule between multiple tasks and with 3 employees. I have manually entered the schedule (52 entries) because I can't think of the math to do it otherwise. I would love a better way to do it, so if anyone has any suggestions that would be great.
I do have two questions that I hope someone could help with.
1. Is there anyway to figure out a date or range of dates if all one know is the week number (yearly week that is 1-52) I currently use the date function to find the appropriate week number but I can't seem to go in the reverse.
2. I am currently suggesting a week number based on the date %V functoin and adding one to it to suggest next weeks week number (week=week+1). The problem I am having is, I can suggest the week and read the variable (pickweek) but I can't let the user just hit enter and capture the suggested week number. The user has to enter it manually. Anyone know how to suggest it based on the date function and then if the user hits enter, accpted that value, or else use the user supplied week.
Any help is appreicated.
Thank you,
mortis... | Hi bashboy,
WRT question #1:
1. Is there anyway to figure out a date or range of dates if all one know is the week number (yearly week that is 1-52) I currently use the date function to find the appropriate week number but I can't seem to go in the reverse.
If you think about it, there are only 14 possible calendars in today's calendar system, i.e. 7 calendars where Jan 1st starts on a different day of the week, and 7 calendars that include a leap day (Feb 29th) for each calendar starting on a different day. Given that one would know which calendar of the 14 applies to a current year, then it might be possible to compute range of dates for the week.
WRT to the 2nd question, if you test the value of the input 'pickweek" for 0 or null let that answer imply "this week" as you have computed it with the %V function of the date command. Otherwise, it must be an input value and you can use that.
-- Tom
__________________ The independence created by philosophical insight is - in my opinion - the mark of distinction
between a mere artisan or specialist and a real seeker after truth. - Einstein 1944
Imagination is more important than knowledge. - Einstein
Last edited by lotuseclat79 : 07-Apr-2007 11:24 AM.
|  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 10:29 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|