home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11998 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  2.5 KB

  1. From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
  2. Date: Mon, 11 Jan 1993 15:01:46 GMT
  3. Subject: Re: Re: batch question
  4. Message-ID: <27540002@hpuamsa.neth.hp.com>
  5. Organization: Hewlett-Packard, The Netherlands
  6. Path: sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpcc05!hpbbn!hpuamsa!franks
  7. Newsgroups: comp.os.msdos.programmer
  8. References: <1ii4vvINNbqs@darkstar.UCSC.EDU>
  9. Lines: 61
  10.  
  11. spencer@cats.ucsc.edu (Michael Spencer) writes:
  12.  
  13. >Gary_Angove@abcd.Houghton.MI.US (Gary Angove) writes:
  14. >
  15. >>I would like to use a batch program from the AUTOEXEC that would preform a
  16. >>particular task dependant on the date.  
  17. >>Such as, ...
  18. >>.........IF CURRENT DATE IS EQUAL TO (SOME DATE) DO....
  19. >>Can this be done through the AUTOEXEC?     HELP!!!!
  20. >
  21. >
  22. >Unfortunately, the answer is NO
  23. >    because batch files cannot effectively access the time program.
  24.  
  25.   I do not agree. First of all since the *time* program is of little use
  26. for determining the *date* :-) and secondly because batch files *can*
  27. effectively access the date program, as is shown in my below posting
  28. (which was accidently posted to comp.sys.ibm.pc.programmer as a response
  29. to the, probably also accidental, posting of Gary Angove to that
  30. obsolete group) :
  31.  
  32. From franks Fri Jan  8 10:51:25 1993
  33. From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
  34. Date: Fri, 8 Jan 1993 09:51:25 GMT
  35. Date-Received: Fri, 8 Jan 1993 09:51:25 GMT
  36. Subject: Re: batch question
  37. Message-ID: <27440001@hpuamsa.neth.hp.com>
  38. Organization: Hewlett-Packard, The Netherlands
  39. Path: hpuamsa!franks
  40. Newsgroups: comp.sys.ibm.pc.programmer
  41. References: <Gary_Angove.0bxs@abcd.Houghton.MI.US>
  42.  
  43.   *Part* of the solution (i.e. how to get the current and desired dates
  44. in two files) :
  45.  
  46.   Earlier:
  47.  
  48. echo. | date >desired
  49.  
  50.   Note: *No* space between "echo" and the dot (.). The "echo." construct
  51. is a little known feature. Note that "echo | date >desired" (i.e.
  52. without the dot) will not work and will hang your system.
  53.  
  54.   In autoexec.bat:
  55.  
  56. echo. | date >current
  57.  
  58.   Next you want to compare the files "current" and "desired" and want to
  59. make a decision (IF statement) on whether they are equal or not. This is
  60. easy with a MS-DOS clone of the UNIX cmp(1) command (like the one in the
  61. MKS toolkit) , but I could not find a solution with either COMP or FC
  62. combined with FIND. If FIND sets an ERRORLEVEL (I do not have the manual
  63. handy), then you can use
  64.  
  65. fc current desired | find "FC: no differences encountered"
  66.  
  67. and do an IF on the ERRORLEVEL returned by FIND.
  68.  
  69.   Hope this helps.
  70.  
  71. Frank Slootweg
  72.