in reply to Re: Redirection with Win9x batch files
in thread Redirection with Win9x batch files

Not to turn this into batchmonks, but you could also get rid of much of the redundancy in that big ol' batch file by using something like this (untested):

:Loop REM If there are no parameters left, just go run perl if !%1! == !! goto doit REM If there's a -L, set the log flag if !%1! == !-L! set log=1 REM If this isn't a -L, push it on to the params stack if not !%1! == !-L! set params=%params% %1 REM Shift that %1 off and continue (%2 is now %1, etc) shift goto Loop :doit if !%log%! == !1! goto Log c:\devt\perl\bin\perl.exe %params% goto ciao :Log c:\devt\perl\bin\perl.exe %params% > stdout.log :ciao set params= set log= echo on

Recursion is your friend!

Replies are listed 'Best First'.
OT: Re...Redirection with Win9x batch files
by footpad (Abbot) on Dec 09, 2000 at 02:44 UTC
    myocom: Excellent! (And I thought I had batch files cold.) ;-)

    Thanks for reminding me that there's always more to learn.

    Blue: Good point. Initially, I wanted to maintain a single batch file, if possible. After continued reflection, this looks like a case where two one-line batch files are easier to understand after the development fit. Any maintenance difficulties could be easily handled with documentation (comments in the batch files). (Which is a nice way of saying, it would help me remember what I was trying to accomplish when I looked at those files later.)

    Anyone have thoughts regarding the utility of unlinking the log files before the system call? Good idea? Bad idea? No matter?

    --f