FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


nt set output/error file





kv
I have a nt batch file which contains several commands. For each call, I have to redirect it to the same output/error file. Is there a way to set the output file and error file before starting execution so that even with no redirection, the output/error goes into respective file?
poppitz
you can redirect the output to a file when you add ">filename" to your batch file call like

Code:
xyz.bat >output.txt
kv
Here is a work around

Code:

@echo off
if  "%1"=="exec" goto exec

%~n0 exec %1 %2 %3 %4 %5 > %~dp0\%~n0.log 2>%~dp0\%~n0_error.log

goto end

:exec
shift

rem your commands here

:end


This will enable logging the output and error of commands just by running the batch file (double click will do)
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.