1.

Solve : make log of batch file?

Answer»

Can you capture the results of a batch file you are currently working with?

Example:

Call “\\server\drive\batchfile” >> “\\server\drive\log\log.txt”



Because the batch file I call has user prompts it just waits for the user input. The problem is that I can not get the batch file to show up to enter the requested data. It creates the log file but it only works up to the section where it asks for user input.

Thanks,
wayne
As you have found out, redirection is an all or nothing proposition. You'll need to go into batchfile and redirect the output of the individual commands but allowing the prompts to continue through to the command area and not the log file.

Might have been able to help more but have no idea what's in batchfile.

Good luck. Quote from: Sidewinder on April 24, 2008, 02:59:09 PM

As you have found out, redirection is an all or nothing proposition. You'll need to go into batchfile and redirect the output of the individual commands but allowing the prompts to continue through to the command area and not the log file.

Might have been able to help more but have no idea what's in batchfile.

Good luck.

here is the first part of the batch file I'm trying to log.

batch:

@echo off
cls

echo configuring current time
echo.

remthis will get the local time
call:gettime hours mins
goto END

:gettime hh nn
setlocal ENABLEEXTENSIONS
remthis will set the local time
for /f "tokens=5-8 delims=:. " %%a in ('echo/^|time') do (
set hh=%%a&set nn=%%b)
if 1%hh% LSS 20 set hh=0%hh%
endlocal&set %1=%hh%&set %2=%nn%&goto time


:time
remputs time in user friendly format
set _time=%hours%:%mins%
remprompt user to select if task should run now
remor a set time
:LOOPA
cls
ECHO.
ECHO.
ECHO please CHOOSE time
ECHO
ECHO.
ECHO A. ECHO A. current time (%_time%) PLUS 15 minutes for processing
ECHO B. set a time to run
ECHO.

SET Choice=
SET /P Choice=Type the letter and PRESS Enter:
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
IF /I '%Choice%'=='A' GOTO ItemA
IF /I '%Choice%'=='B' GOTO ItemB
ECHO "%Choice%" is not valid. Please TRY again.
ECHO.
ping -n 2 localhost > nul
GOTO LoopA


this is only about a 10th of the batch but it gets to this point and stops because it is waiting for user input. The issue I have is that when I call this batch file from my first batch file this one runs but dose not display or allow me to interact with it.

I have got it to work by using the >> "\\server\drive\log\time.log" command after each command I wish to log. I just was trying to just call this batch file log what it dose and then move it to a log file.

thanks again,
Wayne


Discussion

No Comment Found