fisher@sc2a.unige.ch (Markus Fischer) (05/24/89)
In article <7372@bsu-cs.bsu.edu>, todd@stiatl.UUCP (Todd Merriman) writes: [ It is a posting from c.b.i.p, containing an *.exe and a *.doc ] > This program, called "batch", reads its standard input up to > end-of-file, assumes each line is a command for MS-DOS, and executes > it. Thus you can do: > batch < file > and have the "file" contain an MS-DOS command on each line. My question is : Why bother posting _heavy_, copyrighted (!), and compiled C programs, for tasks that can be achieved by a simple batch file ? For example `source.bat' could look something like : @ echo off if exist %1, goto ok echo source: file %1 not found goto end :ok copy %1 \tmp\``tmp''.bat call \tmp\``tmp''.bat del \tmp\``tmp''.bat :end thus `source mybat.txt' is equivalent to `batch < mybat.txt', isn't it ? As for the other usage of Tedd Merriman's `batch.exe', i.e. simply typing `batch', entering the commands, and having them executed; that can also be easily simulated by a `batch.bat' file ! Here it is: ------------------------------------------------------------------------------ :*** Assuming %Tmp% points to a directory (i.e. D:\ or the like) *** @echo off if %1~ == -d~ goto del if %1~ == -D~ goto del if %1~ == -?~ goto help if not exist %Tmp%`TmpBat'.BAT goto new if %1~ == -e~ shift if %1~ == -E~ shift if not %1~ == -n~ if not %1~ == -N~ %Tmp%`TmpBat' %1 %2 %3 %4 %5 %6 %7 %8 %9 :new echo :---: Temporary Batch File :---: > %Tmp%`TmpBat'.BAT if %1~ == -n~ shift if %1~ == -N~ shift if not %1~ == -e~ if not %1~ == -E~ goto echo_off echo @echo on >> %Tmp%`TmpBat'.BAT shift :echo_off echo Enter your commands below (F6 or ^Z when finished, ^C to cancel) : type CON >> %Tmp%`TmpBat'.BAT %Tmp%`TmpBat' %1 %2 %3 %4 %5 %6 %7 %8 %8 :help echo.BATCH is a batch-building batch file, creating the file %Tmp%`TmpBatch'.BAT echo. If the file exists, `batch' calles that file; if not, it is created echo. from user input. echo.Switches: -? prints this message and performs `-d' echo. -d deletes the tmp-batch file echo. -n forces the writing of a new tmp-batch file echo. -e forces echo on when writing a new tmp-file echo. :del if exist %Tmp%`TmpBat'.BAT del %Tmp%`TmpBat'.BAT ------------------------------------------------------------------------------ The `*.bat' version has even a serious advantage: it can be used to initalize for-loops, as it accepts command-line parameters ! For example (capitals are computer responses): > batch -d (deleting the tmp-batch file) > for %f in (*.bat) do call batch %f > CALL BATCH FIRST.BAT ENTER YOUR COMMANDS BELOW (F6 OR ^Z WHEN FINISHED, ^C TO CANCEL) : copy %1 *.old edit %1 ^Z 1 FILE COPIED [EDITING] > CALL BATCH SECOND.BAT 1 FILE COPIED [EDITING] > CALL BATCH THIRD.BAT [...] Well, maybe I missed the point of Merriman's `batch.exe'. Else, I think that is typically a little C-exercise, maybe suited for source-posting; but the executable seems quite off the point to me. No hard feelings ? Markus Fischer -|--|--|--|--|--|--I Department of Anthropology -|--|--|--|--|--|--|-(#)-I University of Geneva -|--|--|--|--|--|--|--|--|-(#)-|-(#)(#)(_)-I CH-1227 Carouge (GE) -&-(_)-|--|--|-(#)-&--|-(#)(#)(_)(#)-&-(_)(#)-I Switzerland -|--|--|--|--|-(#)(_)-|-(_)(_)(_)(#)-I black (#) to kill ! --|--|-(#)(_)(_)(_)(#)(#)(_)(_) fisher@sc2a.unige.ch =+==+==+==+==+==+==+==+==+==+==+==+==+==+==+=(#)=+ fisher@cgeuge52.bitnet