Script to detect day of week

Script to detect day of week

Post by Jeff Arnho » Fri, 23 Dec 1994 13:09:40



Does anyone have a shell or perl script which will run a command
and save standard out dependent on the day of the week?  For example:

if today = Monday
        ps > /var/adm/monday.ps
fi

if today = Tuesday
        ps > /var/adm/tuesday.ps
fi

etc.

This is simple, I'm sure, but I don't know the syntax nor have an
example to build off of.

Thanks,

Jeff Arnholt
--


Mayo Medical and Graduate Schools        
200 1st St. SW, Rochester, MN 55905

 
 
 

Script to detect day of week

Post by Hegan Bel » Sun, 25 Dec 1994 01:03:16



>Does anyone have a shell or perl script which will run a command
>and save standard out dependent on the day of the week?  For example:

stuff deleted

The following is something that might help.  It does different things
based on the day of the week.  I wrote it when I first compiled perl on
my system and I was just playing around learning how it worked.

<<<<<<<<<<<<<<<<<<<<<< perl script follows >>>>>>>>>>>>>>>>>>

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$ampm = 'am';
if ($hour > 11) {$ampm = 'pm'};
if ($hour > 12) {$hour = $hour - 12};
if ($min < 10) {$min = join('','0',$min)};
if ($wday == 1)
{
 print ('************************************',"\n",
        '>>>>>>>>>>Weelky Notes Day<<<<<<<<<<',"\n",
        '************************************',"\n")

Quote:};

if ($wday == 4)
{
 for ($i = 1; $i <= 1; $i++)
 {
  system('clear');
  print ('    TTTTTT II MM   MM EEEEE',"\n",
         '      TT   II MMM MMM EE   ',"\n",
         '      TT   II MMMMMMM EEEE ',"\n",
         '      TT   II MM M MM EE   ',"\n",
         '      TT   II MM   MM EEEEE',"\n",
                                       "\n",
         ' SSSSSS HH  HH EEEEE EEEEE TTTTTT',"\n",
         ' SS     HH  HH EE    EE      TT  ',"\n",
         ' SSSSSS HHHHHH EEEE  EEEE    TT  ',"\n",
         '     SS HH  HH EE    EE      TT  ',"\n",
         ' SSSSSS HH  HH EEEEE EEEEE   TT  ',"\n",
                                             "\n",
         '    DDDD       AA    YY    YY',"\n",
         '    DD  DD    AAAA    YY  YY ',"\n",
         '    DD  DD   AA  AA     YY   ',"\n",
         '    DD  DD  AAAAAAAA    YY   ',"\n",
         '    DDDD   AA      AA   YY   ',"\n",
                                         "\n",
                                         "\n");
 };
Quote:};

$WeekDayName =
(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[$wday];
$mon++;
print
($WeekDayName,' ',$mon,'/',$mday,'/',$year,'
',$hour,':',$min,$ampm,"\n");

<<<<<<<<<<<<<<<<<< end perl script >>>>>>>>>>>>>>>>>>>>>>

 
 
 

Script to detect day of week

Post by Kirk Raffer » Sun, 25 Dec 1994 01:31:28


: Does anyone have a shell or perl script which will run a command
: and save standard out dependent on the day of the week?  For example:

<stuff deleted>

how about:
-------------------------------------
#!/bin/sh

Today=`date +%A`

case $Today in
   Monday) psfile=monday.ps ;;
   Tuesday) psfile=tuesday.ps ;;
esac

ps > /var/adm/$psfile

-------------------------------------

the %A parameter causes date to only report the full day of the week.
you may want to check it for every day of the week on your system to
make sure you match it correctly in the case statement.

--
Kirk Rafferty
Lewan and Associates       Phone: (303) 759-5440 x355
1400 South Colorado Blvd   Fax:   (303) 759-8925

 
 
 

Script to detect day of week

Post by Bill Marc » Mon, 26 Dec 1994 07:54:03


Some versions of date don't support %A.  You could use %w which gives the
day of the week as a number from 0 to 6 with Sunday=0.

--

"Bah humbug everybody!"
                       "Good morning, Mister Scrooge!"

 
 
 

1. script to keep day, week, month backup file

If every night I copy file X sideways as backups/X[date], eg
backups/X03122004. Then also, every night, I want to purge the backups/
directory - BUT keeping last nights, last fridays and last months file X.

How can I achieve this in a shell script? I'd like to avoid perl if
possible. I have searched groups with no result. Please aim your response at
a scripting beginner!

Thanks in advance

2. SNMP Daemon for Solaris 2.4

3. day of week script

4. Linux in 386 Boxes

5. Need script to return a day of the week number

6. hdc: lost interrupt

7. How determine day of week from YYMMDD?

8. Help: X 3.1.1 and ALVGA 2101

9. How to findout the week of the day.

10. how to change first day of week

11. date -> day of week

12. Is there a way to compute what nth day of the year/week it is now?

13. Day of the week