[comp.os.msdos.programmer] More on my batch file problem

migdol@emx.utexas.edu (Michael A. Migdol) (05/23/91)

     Ok, maybe I'm an idiot for trying to do this, but here's a summary of
my efforts: I'm trying to run several applications in a row from a batch
file. For various reasons, I've concluded that the machine needs to reboot
between applications. So, here's what I've got:

batch1
copy \autoexec.bat \autoexec.tmp
appl1
copy batch2 \autoexec.bat
reboot { a small program I wrote to cold boot the machine }

batch2
appl 2    
copy batch3 \autoexec.bat
reboot

batch3
appl3
copy \autoexec.tmp \autoexec.bat
reboot

Make sense? The problem is that the batch file is writing over itself...does
anyone have any suggestions? 

Thanks in advance!


*****************************************************************************
*  Michael A. Migdol                  |    Disclaimer:                      *
*  migdol@emx.utexas.edu              |       "I may be wrong"              *
*  University of Texas, Austin        |           (Thanks Robert Fulghum!)  *
*****************************************************************************
*               "There's no such thing as a simple miracle"                 *
*****************************************************************************

a_rubin@dsg4.dse.beckman.com (05/23/91)

In <49380@ut-emx.uucp> migdol@emx.utexas.edu (Michael A. Migdol) writes:


>     Ok, maybe I'm an idiot for trying to do this, but here's a summary of
>my efforts: I'm trying to run several applications in a row from a batch
>file. For various reasons, I've concluded that the machine needs to reboot
>between applications. So, here's what I've got:

How about this:

batch1
copy \autoexec.bat \autoexec.tmp
appl1
restart batch2 

batch2
appl2    
restart batch3 

batch3
appl3
restart \autoexec.tmp 

restart
copy %1 \autoexec.bat
reboot

--
a_rubin@dsg4.dse.beckman.com  
My opinions are my own, and do not represent those of my employer.

reaper@wixer.helps.cs.utexas.edu (Keath Milligan) (05/23/91)

MS-DOS reads batch files as they are being executed one line at a time.  Batch 
files can either execute another batch file and return to the original or they 
can chain to another batch file (ie, stop executing one and start executing
another).

To call one batch file from within another use:

	CALL <batch file name>

<batch file name> may be specified with or without the .BAT exentension.  CALL
will search the path for the batch file just as if it had been executed from 
the command line.  MS-DOS will read and execute ths batch file, when it is
finished, it will continue executing the original batch file.

To stop executing one batch file and start executing another ("chaining"),
simply use the batch file name as usual.

Examples:

	path C:\DOS;C:\BATCAVE;C:\TOOLS

	rem This will execute BATCH1 and return

	CALL BATCH1

	echo <back to the original file>

	rem This will stop executing this batch file and start executing BATCH2

	BATCH2

	rem Commands below "BATCH2" won't be executed.

cgordon@vpnet.chi.il.us (gordon hlavenka) (05/24/91)

In article <49380@ut-emx.uucp> migdol@emx.utexas.edu (Michael A. Migdol) writes:
>
>     Ok, maybe I'm an idiot for trying to do this, but here's a summary of
>my efforts: I'm trying to run several applications in a row from a batch
>file. For various reasons, I've concluded that the machine needs to reboot
>between applications. So, here's what I've got:


I have done this before.  I needed to LL format, FDISK, DOS format, and scan
a couple dozen hard drives, so I set up a boot disk with script files and
stuff to do it.  The machine had to reboot three times for each drive.

I used a set of batch files called PASS1.BAT, PASS2.BAT, and PASS3.BAT to do
whatever was required for each pass.  PASS1.BAT contained the line:
     rem stuff you need to do first...
     ECHO xxx > PASS2
     REBOOT

PASS2.BAT contained the lines:
     rem stuff you need to do in the middle...
     IF EXIST PASS2 DEL PASS2
     ECHO xxx > PASS3
     REBOOT

PASS3.BAT contained the line:
     rem stuff you need to do last...
     IF EXIST PASS3 DEL PASS3

AUTOEXEC.BAT looked like this:
     IF EXIST PASS2 PASS2
     IF EXIST PASS3 PASS3
     PASS1

This seemed to sequence nicely.

Of course, if things work properly, you don't need the "IF EXIST"s in
PASS?.BAT, but I'm paranoid.


-- 
-----------------------------------------------------
Gordon S. Hlavenka            cgordon@vpnet.chi.il.us
Disclaimer:                Yeah, I said it.  So what?

rdippold@cancun.qualcomm.com (Ron Dippold) (05/24/91)

In article <49380@ut-emx.uucp> migdol@emx.utexas.edu (Michael A. Migdol) writes:
>
>     Ok, maybe I'm an idiot for trying to do this, but here's a summary of
>my efforts: I'm trying to run several applications in a row from a batch
>file. For various reasons, I've concluded that the machine needs to reboot
>between applications. So, here's what I've got:
>[...]
>Make sense? The problem is that the batch file is writing over itself...does
>anyone have any suggestions? 

If you're using a disk cache program that does staged writes, such as Hyper
Disk Cache, running reboot will bypass the normal protection that the program
has to keep you from rebooting your machine before all queued up sectors are
written to the disk.  If that is the case, put a pause before the reboots.
-- 
Standard disclaimer applies, you legalistic hacks.     |     Ron Dippold