1745798 Members
3660 Online
108722 Solutions
New Discussion юеВ

Re: Report script

 
SOLVED
Go to solution
wayne_104
Regular Advisor

Re: Report script

Okay The customer wants to now do backups fro the rest of the week days.

I made the following modification but it does not work.

I donot see the file in /tmp

what have i done wrong?

#!/usr/bin/ksh

function get_first_sunday
{
typeset month=$1 year=$2

typeset -Z02 first_sunday=$( cal $month $year | awk 'NR == 3 { print $NF }' )

print "Sun" $year $month $first_sunday
}
function get_other_day
{
typeset month=$1 year=$2

typeset -Z02 other_day=$( cal $month $year )

print "other" $year $month $other_day
}

typeset wday month year
typeset -Z02 mday

date +'%a %m %e %Y' | read wday month mday year

typeset first_sunday_of_the_year=$( get_first_sunday 01 $year )
typeset first_sunday_of_june=$( get_first_sunday 06 $year )
typeset first_sunday_of_the_month=$( get_first_sunday $month $year )
typeset other_day=$( get_other_day $month $year )
echo "$other_day"
echo $first_sunday_of_the_year
echo $first_sunday_of_june
echo $first_sunday_of_the_month


case "$wday $year $month $mday" in

"$first_sunday_of_the_year")
echo "First sunday of the year" > /tmp/First_year.txt
;;
"$first_sunday_of_june")
echo "First sunday of June" > /tmp/First_june.txt
;;
"$first_sunday_of_the_month")
echo "First sunday of the month" > /tmp/First_month.txt
;;
"$other_day")
echo "Other" > /tmp/otherday.txt
;;
Sun*)
echo "Other" > /tmp/sunday.txt
;;

esac
Dennis Handly
Acclaimed Contributor

Re: Report script

Add the following to the end of your case:
*) echo "no match $other_day" ;;

There may be a spacing problem in your get_other_day function? Also how does the string "other" ever match $wday?
wayne_104
Regular Advisor

Re: Report script

I cant answer your question because i do not understand The wday thing.

I am new to this and just when i thought i understood i found i did not.
Dennis Handly
Acclaimed Contributor

Re: Report script

>I do not understand the wday thing.

To get a match in the case, these strings must match:
echo "$wday $year $month $mday"
echo "$other_day"
wayne_104
Regular Advisor

Re: Report script

ok i get it now thank you for all your help.

wayne_104
Regular Advisor

Re: Report script

Man i have a long way to go with this stuff

Thanks for your help
Dennis Handly
Acclaimed Contributor

Re: Report script

>I get it now thank you for all your help.

You can of course use a wildcard at the end of your case that matches all other cases:
*)
echo "Other" > /tmp/otherday.txt ;;

And remove your "$other_day" case.
wayne_104
Regular Advisor

Re: Report script

That is exactly what I did.