Command Line Options / Logfile

Asked by Mike Praeuner on 2019-05-16

Starting Here:
https://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html

from a batch file I am running
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\ErisEvE" -f "d:\mike\Sikuli Scripts\LogEvEHealth.txt"

Which creates LogEvEHealth.txt and logs that session

I tried this:
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\ErisHealth" >> d:\mike\Sikuli Scripts\LogErisHealth.txt
but the syntax must be wrong somewhere....

Any way to add timestamp / append next session? (using JYthon in SikuliX IDE 1.1.4)

I read a few other answers but wasn't sure the best route:
https://www.robvanderwoude.com/battech_redirection.php
https://answers.launchpad.net/sikuli/+question/248604
https://answers.launchpad.net/sikuli/+question/595513

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Mike Praeuner
Solved:
2019-05-17
Last query:
2019-05-17
Last reply:
2019-05-17
Mike Praeuner (eris667) said : #1

Found this....
https://bugs.launchpad.net/sikuli/+bug/1486873

Using this:
Debug.setLogFile("D:\\Mike\\Sikuli Scripts\\testfunction.log")

I get a file created for current session that is overwritten by the next session

RaiMan (raimund-hocke) said : #2

solved?

Mike Praeuner (eris667) said : #3

still experimenting but this is my current solution (solved)

--batch file--
@echo off
set starttime=%TIME%
set startcsec=%STARTTIME:~9,2%
set startsecs=%STARTTIME:~6,2%
set startmins=%STARTTIME:~3,2%
set starthour=%STARTTIME:~0,2%
set /a starttime=(%starthour%*60*60*100)+(%startmins%*60*100)+(%startsecs%*100)+(%startcsec%)
:TimeThis
rem setup environment
@echo on
taskkill /f /im nox*
taskkill /f /im java*
PATH=%PATH%;D:\MikE\Sikuli Scripts\
nircmd.exe monitor on
nircmd.exe setcursor 100 50
nircmd.exe movecursor 10 10
@echo off
rem a way to stop from progressing
timeout 30
@echo on
>>"d:\mike\Sikuli Scripts\Collect.log" (
echo --------------------------------------------------------------------------------------------
echo %date%-%time%
echo --------------------------------------------------------------------------------------------
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect1"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect2"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect3"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect4"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect5"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect6"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect7"
timeout 1
java -jar "d:\MikE\sikulix.jar" -r "d:\mike\Sikuli Scripts\Collect8"
)
@echo off
set endtime=%time%
set endcsec=%endTIME:~9,2%
set endsecs=%endTIME:~6,2%
set endmins=%endTIME:~3,2%
set endhour=%endTIME:~0,2%
if %endhour% LSS %starthour% set /a endhour+=24
set /a endtime=(%endhour%*60*60*100)+(%endmins%*60*100)+(%endsecs%*100)+(%endcsec%)
set /a timetaken= ( %endtime% - %starttime% )
set /a timetakens= %timetaken% / 100
set timetaken=%timetakens%.%timetaken:~-2%

rem end script
rem teardown environment
taskkill /f /im nox*
taskkill /f /im java*
rem last updated 5/12/19
>>"d:\mike\Sikuli Scripts\Collect.log" (
echo --------------------------------------------------------------------------------------------
echo %date%-%time%
echo --------------------------------------------------------------------------------------------
echo.
echo Took: %timetaken% sec.
)
timeout 300
rem pause

References:
https://www.windows-commandline.com/get-date-time-batch-file/
https://stackoverflow.com/questions/20484151/redirecting-output-from-within-batch-file