No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help
View Responses


Grex Test Item 34: Automatically setting my perms depending on the hour and day
Entered by popcorn on Sun Oct 6 07:09:41 UTC 1991:

This item text has been erased.

4 responses total.



#1 of 4 by remmers on Sun Oct 6 13:12:23 1991:

The C shell itself can do numeric comparison, Boolean operations,
and if-else control flow, so I think you can avoid awk.  How about
something like this?

 set date = `date '+ %w %H'`
 if ($date[1] == 0 || $date[1] == 6 || ($date[2] > 5 && $date[2] < 22)) then
  mesg y
 else
  mesg n
 endif



#2 of 4 by mdw on Sun Oct 6 13:43:07 1991:

You definitely want to get rid of the "temp.mesg" file, and not using
awk is another win.  Even with awk, it's a bit silly to pass it strings
like "Day of Week", since awk doesn't really understand English.  John's
example is much better on all these counts.  As it happens, the c shell
can also do alphabetical comparisons, so it should be a somewhat
straight-forward extension to extend John's example to handling
Valerie's "known bugs".

This could also be done with the Bourne shell, albeit not quite as
cleanly.  The trick there would be to use the "case" statement, which
doesn't involve forking another program (unlike '['--an alias for 'test'
on many systems), yet is capable of doing fairly complex pattern
matching.


#3 of 4 by mju on Sun Oct 6 20:42:28 1991:

(Most modern Bourne shells -- by "modern", I mean most SysV versions, and
perhaps 4.3BSD as well -- have "test" and "[" implimented as builtins,
so you don't have the overhead of forking a /bin/test.  Still, Marcus's
point is well taken; you definitely want to avoid forking a new process
whenever you can.  In this case, it might be faster to write a C program
to do a time() followed by a localtime() to figure out what time it is,
and then print "mesg y" or "mesg n" depending on what behavior is
appropriate.)


#4 of 4 by popcorn on Sun Oct 6 20:52:37 1991:

This response has been erased.

Response not possible - You must register and login before posting.

No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss