|
|
This item text has been erased.
4 responses total.
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
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.
(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.)
This response has been erased.
Response not possible - You must register and login before posting.
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss