Auto copying archived web reports

(imported topic written by SystemAdmin)

I have a Web Report that is archived daily which I would like copied to another server by using the Customized Executable feature. I am currently attempting to use a batch file but am having problems because each report is put into a new folder with a name of 10 different numbers with no apparent pattern, e.g. 1166653742 or 1166655002. The server I’m copying the reports to needs AD credentials to connect, in the batch file I was using Net Use. I was thinking of pulling the folder with the most recent creation date but I don’t know the syntax and was hoping someone has done this before.

~ Jason

(imported comment written by BenKus)

Hi Jason,

The 10 digit number is the number of seconds since 1970 (which is just an easy way to make sure that the folder names don’t collide). Our documentation on the custom executables is fairly sparse, but this might help… In the web reports help for Custom Executables, it reads:

+Customized Executable

The selected executable will run with the given arguments if the scheduled activity’s triggers are met. The executable will run as the Web Reports service’s user, and will run through the shell. It will run in the background without UI.

There are several special reserved parameters that can pass information about the activity to the executable:

: the scheduled activity’s name

: the file containing the generated report

: the scheduled activity’s creator

It sounds like if you use the “reportfile” parameter for your batch script, it will give it a path to the file you want so you can copy it.

Please post when you get this working and if you post your batch script code, I think lots of other people will benefit from it because it seems like something lots of people want to do.

Ben

(imported comment written by SystemAdmin)

Ben,

I’m still having a little problem with the pathname for the Web Report. In Web Reports I specify my batch file as the executable and for the arguments I put: “” (Through trial and error I found you have to include the quotes if the path has spaces).

The pathname for the archive should be: “D:\Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\TestArchive\1167762902\archive.csv”

For working with parameters in batch files I looked here: http://www.windowsitpro.com/Article/ArticleID/13443/13443.html?Ad=1

In the batch file I echoed the parameter into txt files with the following results:

echo %1 = “D:\Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\custom-4.dat”

echo %~p1 = \Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\

echo %~n1 = custom-4

echo %~dp1 = D:\Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\

echo %~sp1 = \PROGRA~1\BIGFIX~1\BESSER~1\BESREP~2\ARCHIV~1\

Do you know why doesn’t return the direct parent folder of the archive? Where can I access the Web Reports help; I read through http://support.bigfix.com/product/documents/BESWebReports-6.0.pdf originally but didn’t find anything. ~ Jason

(imported comment written by BenKus)

Hey Jason,

The file “D:\Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\custom-4.dat” is the output that is created for your report. The file “D:\Program Files\BigFix Enterprise\BES Server\BESReportsData\ArchiveData\TestArchive\1167762902\archive.csv” is created because you chose to archive the file in addition to the custom report.

You can copy the custom-4.dat file somewhere else (rename it if you want) using the batch script and you can verify it is the file you want.

Ben

(imported comment written by SystemAdmin)

Well it worked! I never saw custom-4.dat in Explorer (even with hidden files and system files showing) and I thought I had tried to copy that full path before but it didn’t work. I also discovered I could have gotten the file from “…\ArchiveData\LastRunReports” where the # in #.dat matches the Report ID in WebReports. Thank you Ben for your help. ~ Jason

BATCH FILE:

REM Create Current Date Variable, Current Date Code from: http://www.tech-recipes.com/computer_programming_tips956.html

FOR /F "TOKENS=1* DELIMS= " %%A IN (‘DATE/T’) DO SET CDATE=%%B

FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN (‘DATE/T’) DO SET mm=%%B

FOR /F “TOKENS=1,2 DELIMS=/ eol=/” %%A IN (‘echo %CDATE%’) DO SET dd=%%B

FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN (‘echo %CDATE%’) DO SET yyyy=%%B

SET date=%yyyy%%mm%%dd%

REM Map Server Share to X:

NET USE X: “\server\share” password /USER:domain\username

REM Copy report with the pathname passed in as a parameter from WebReports. Put “” in the arguments, including the quotes.

copy %1 “X:%date%DailyReport.csv”

REM Disconnect X: Drive

NET USE X: /DELETE