Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Supporting Task - External Program (.bat file) - output?

When a supporting task is triggered, a log file is generated by the QlikView server.  Is it possible to write the output of the external program to the same log?

James

4 Replies
Miguel_Angel_Baeyens

Hi James,

You can append the standard output to any file using

Batchfile >> Logfile

And create the same log format (date, time, and the rest of the fields) so the log keeps the fields.

QlikView Server stores logs into C:\ProgramData\QlikTech The destination folder will depend on the service -Web Server, Publisher, Server...

@ECHO OFF

SET COMPLETEDATE=%DATE% %TIME%

ECHO %COMPLETEDATE% Log text here

Will write date, time and "Log text here" into the folder specified after the ">>" when calling the .bat file

log.bat >> logfile.txt

Hope that helps.

Miguel

Not applicable
Author

Miguel,

very helpful, thanks.

would you happen to know how to determine the name of the logfile generated by the server?

for example, the log file name from this morning is:

C:\ProgramData\QlikTech\DistributionService\1\Log\20120119\070000 - ADA003 - Copy QVDs to QlikTest Server\TaskLog.txt

Most of the file name is static.  The date and time stamp is variable and will be different for each run.  My first thought was to redirect the output in the batch file to the current date/time.  But that will only work IF the time elapsed is less than 1 second.

Perhaps there is a QV variable available to the batch file?  fingers crossed...

James

Miguel_Angel_Baeyens

Sorry James,

What do yo mean by "QV variable available to the batch file"? I missed that part. The name of the folder is the current date, so that part is just fine with the batch process. The time could be fixed if you have scheduled a reload on a certain time, and not on event of another task. So that part would be ok as well. And the rest of the name is fixed as well. So you need a bit of string formatting in the batch process to look like YYYYMMDD and hhmmss:

@ECHO OFF

SET VARDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%

SET VARTIME=%TIME:~0,2%%TIME:~3,2%00

SET TIMESTAMP=%VARDATE% %VARTIME%

ECHO %TIMESTAMP% Log text here

The result of this batch should be:

20120119 151400 Log text here

Now elaborate the script to change directory to the current date and the name of your file to get the complete file name.

Hope that helps.

Miguel

Not applicable
Author

Miguel,

thanks for you help.  It certainly sent me in the right direction.

After tweaking the code a bit, I was able to write to a log file in the same location as the TaskLog.txt file.

SET VARDATE=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
SET VARTIME=%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
SET TIMESTAMP=%VARDATE% %VARTIME%
SET LOGFILENAME="C:\ProgramData\QlikTech\DistributionService\1\Log\%VARDATE%\%VARTIME% - ADA003 - Copy QVDs to QlikTest Server\CmdLog.txt"
ECHO Batch command file execution started... > %LOGFILENAME%
REM commands removed to protect the innocent, like SOPA supporters...

ECHO Batch command file execution completed...>> %LOGFILENAME%

James