🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7595

Re: Re: batch question

#7595
From: Frank Slootweg CRC
Date: Mon, 11 Jan 1993 15:01
61 lines
2602 bytes
spencer@cats.ucsc.edu (Michael Spencer) writes:

>Gary_Angove@abcd.Houghton.MI.US (Gary Angove) writes:
>
>>I would like to use a batch program from the AUTOEXEC that would preform a
>>particular task dependant on the date.  
>>Such as, ...
>>.........IF CURRENT DATE IS EQUAL TO (SOME DATE) DO....
>>Can this be done through the AUTOEXEC?     HELP!!!!
>
>
>Unfortunately, the answer is NO
>	because batch files cannot effectively access the time program.

  I do not agree. First of all since the *time* program is of little use
for determining the *date* :-) and secondly because batch files *can*
effectively access the date program, as is shown in my below posting
(which was accidently posted to comp.sys.ibm.pc.programmer as a response
to the, probably also accidental, posting of Gary Angove to that
obsolete group) :

From franks Fri Jan  8 10:51:25 1993
From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
Date: Fri, 8 Jan 1993 09:51:25 GMT
Date-Received: Fri, 8 Jan 1993 09:51:25 GMT
Subject: Re: batch question
Message-ID: <27440001@hpuamsa.neth.hp.com>
Organization: Hewlett-Packard, The Netherlands
Path: hpuamsa!franks
Newsgroups: comp.sys.ibm.pc.programmer
References: <Gary_Angove.0bxs@abcd.Houghton.MI.US>

  *Part* of the solution (i.e. how to get the current and desired dates
in two files) :

  Earlier:

echo. | date >desired

  Note: *No* space between "echo" and the dot (.). The "echo." construct
is a little known feature. Note that "echo | date >desired" (i.e.
without the dot) will not work and will hang your system.

  In autoexec.bat:

echo. | date >current

  Next you want to compare the files "current" and "desired" and want to
make a decision (IF statement) on whether they are equal or not. This is
easy with a MS-DOS clone of the UNIX cmp(1) command (like the one in the
MKS toolkit) , but I could not find a solution with either COMP or FC
combined with FIND. If FIND sets an ERRORLEVEL (I do not have the manual
handy), then you can use

fc current desired | find "FC: no differences encountered"

and do an IF on the ERRORLEVEL returned by FIND.

  Hope this helps.

Frank Slootweg
Technical Details
Message-ID: <27540002@hpuamsa.neth.hp.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpcc05!hpbbn!hpuamsa!franks
References: <1ii4vvINNbqs@darkstar.UCSC.EDU>

Show Full Headers
Complete Article Headers
From: franks@hpuamsa.neth.hp.com (Frank Slootweg CRC)
Date: Mon, 11 Jan 1993 15:01:46 GMT
Subject: Re: Re: batch question
Message-ID: <27540002@hpuamsa.neth.hp.com>
Organization: Hewlett-Packard, The Netherlands
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpcc05!hpbbn!hpuamsa!franks
Newsgroups: comp.os.msdos.programmer
References: <1ii4vvINNbqs@darkstar.UCSC.EDU>
Lines: 61