Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(probably) dumb question about BAT files

1 view
Skip to first unread message

Six Lombardi's

unread,
Jul 17, 2009, 2:54:20 PM7/17/09
to
The other day I was running a BAT file to run a few stored procedures
from a SQL Server.

While the BAT file was running, I added a couple of new lines of DOS
code to shoot an email out to a few people to let them kno wthe
process was starting.

When the BAT file finished running the stored procedure it was
processing, it started to RE-RUN the same stored procedure!

I was working on the assumption that a BAT file works like a SQL
stored procedure, in that you could edit it while you're running it
and it would just run whatever code was in the BAT file when it was
originally launched. Does anyone know if a BAT file checks for
updates in the middle of proceessing?

foxidrive

unread,
Jul 17, 2009, 3:20:44 PM7/17/09
to
On Fri, 17 Jul 2009 11:54:20 -0700 (PDT), "Six Lombardi's"
<manni...@gmail.com> wrote:

>When the BAT file finished running the stored procedure it was
>processing, it started to RE-RUN the same stored procedure!
>
>I was working on the assumption that a BAT file works like a SQL
>stored procedure, in that you could edit it while you're running it
>and it would just run whatever code was in the BAT file when it was
>originally launched. Does anyone know if a BAT file checks for
>updates in the middle of proceessing?

Some conventional wisdom of the old days said that a batch file was opened,
a line read and pointer saved, the batch file was closed and when that line
completed the batch file was reopened and the next line read.

If a running batch file was edited then unpredictable behaviour can occur.

The usual approach is *don't edit a running batch file*.

ArarghMai...@not.at.arargh.com

unread,
Jul 17, 2009, 7:35:55 PM7/17/09
to
On Sat, 18 Jul 2009 05:20:44 +1000, foxidrive <got...@woohoo.invalid>
wrote:

Maybe: Make a copy, run the copy, modify the original?
--
ArarghMail907 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the extra stuff from the reply address.

Todd Vargo

unread,
Jul 18, 2009, 9:32:36 AM7/18/09
to
Arargh wrote:
> foxidrive wrote:

> >Six Lombardi's wrote:
> >
> >>When the BAT file finished running the stored procedure it was
> >>processing, it started to RE-RUN the same stored procedure!
> >>
> >>I was working on the assumption that a BAT file works like a SQL
> >>stored procedure, in that you could edit it while you're running it
> >>and it would just run whatever code was in the BAT file when it was
> >>originally launched. Does anyone know if a BAT file checks for
> >>updates in the middle of proceessing?
> >
> >Some conventional wisdom of the old days said that a batch file was
opened,
> >a line read and pointer saved, the batch file was closed and when that
line
> >completed the batch file was reopened and the next line read.
> >
> >If a running batch file was edited then unpredictable behaviour can
occur.
> >
> >The usual approach is *don't edit a running batch file*.
>
> Maybe: Make a copy, run the copy, modify the original?

foxidrive's so-called "approach" is more of a 'fundamental rule' of editing
batch files. The rule simply restated...

Never edit a running batch file. Unpredictable behavior can occur (and
usually does) when changes are made to a running batch file.

I use the copy, run the copy, approach myself on occasion.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

0 new messages