in reply to Redirection with Win9x batch files

footpad, I admit up front that I don't use MS-(DOS|Win3?) batch very oftern (I"m a Unix SA), but couldn't you simplify the task simply by having two batch scripts, one which called Perl, and one which called Perl and redirected the output.

c:\devt\perl\bin\perl.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 > stdout.log No need for all the extra checking. Frankly, the batch processing isn't all that powerful. I look at the alternative example and cringe. (Not at you, but at the lack of power of the batch.)

"Beware of false laziness" is the council in one of the zoo books. I think this may be a case of it. 8)

BTW, thorough doing of your homework. Still a ++ for good forethought.

=Blue
...you might be eaten by a grue...

Replies are listed 'Best First'.
Re: Re: Redirection with Win9x batch files
by myocom (Deacon) on Dec 09, 2000 at 01:23 UTC

    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!

      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