WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Batch file - handling errors
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1132751998

Message started by Loz on Nov 23rd, 2005 at 2:19pm

Title: Batch file - handling errors
Post by Loz on Nov 23rd, 2005 at 2:19pm
hi

version 2.5.0

My batch file picks up new XML files and turns them into PDFs.  I would like to print the PDF after its creation (within the same batch file).  However, after the PDF is created the batch file seems to end...

code snipet...  I wrapped the PDF creation with log entries...

ECHO [X][%WD_DTTM%] Hello world >> "%WD_LOGFILE%"

c:\progra~1\altova\fop\fop -xsl "%XSLFILE%" -xml "%WD_FILE%" -pdf "%PDFTARGET%"

ECHO [X][%WD_DTTM%] Hello world 2 >> "%WD_LOGFILE%"


Looking at the log file, "hello world 2" does not get executed....

What do you think?


Also - watch monitor (version 3.2.7) - does a later version of watch directory allow column sorting of 'watching directory' or 'start command'...  if not, can you add it to your devleopment request list. many thanks

Also! on 3.2.7 - I cannot open entries in another users start up folder... (this i need to do!).  can I have a browse file button (similar to the *.watchdir file browse)?  

Thanks for your time and excellent product.

Loz

Title: Re: Batch file - handling errors
Post by Gert on Nov 23rd, 2005 at 6:35pm

Loz wrote on Nov 23rd, 2005 at 2:19pm:
hi
ECHO [X][%WD_DTTM%] Hello world >> "%WD_LOGFILE%"
c:\progra~1\altova\fop\fop -xsl "%XSLFILE%" -xml "%WD_FILE%" -pdf "%PDFTARGET%"
ECHO [X][%WD_DTTM%] Hello world 2 >> "%WD_LOGFILE%"

Looking at the log file, "hello world 2" does not get executed....


If you change the last line to
ECHO [X][%WD_DTTM%] Bye Bye World >> "%WD_LOGFILE%"
does it work then?

You have to take care with your last echo, because 2>> means:
"write the errors from the command to the left of '2>>' to the file to the right of '2>>'"



Loz wrote on Nov 23rd, 2005 at 2:19pm:
version 2.5.0
...
Also - watch monitor (version 3.2.7)...

Now, I'm not sure what version you are using (2.5 or 3.2.7)...


Loz wrote on Nov 23rd, 2005 at 2:19pm:
Also - watch monitor (version 3.2.7) - does a later version of watch directory allow column sorting of 'watching directory' or 'start command'...  if not, can you add it to your devleopment request list. many thanks

There are no plans to release a new version for the 3.x series (all development is on 4.x).



Loz wrote on Nov 23rd, 2005 at 2:19pm:
Also! on 3.2.7 - I cannot open entries in another users start up folder... (this i need to do!).  can I have a browse file button (similar to the *.watchdir file browse)?  


Just use the "browse for a watchdir file" feature, and navigate to
C:\Documents and Settings\USERNAME\Start Menu\Programs\Startup

then, enter a single * inside the File Name box of the browse dialog. You can now see all shortcuts of the user's startup menu.
Select the shortcut you want to change.

*.watchdir files have the same layout (binary compatible) as *.lnk (shortcut) files. Remember that you need to save this .lnk file using "save as watchdir file" (no new name) to replace it inside the user's startup menu.

Gert

Title: Re: Batch file - handling errors
Post by Loz on Nov 24th, 2005 at 1:51am
Thanks Gert.

NO luck. I have changed the .bat to:

ECHO [X][%WD_DTTM%] Hello GdP world >> "%WD_LOGFILE%"

c:\progra~1\altova\fop\fop -xsl "%XSLFILE%" -xml "%WD_FILE%" -pdf "%PDFTARGET%"

ECHO [X][%WD_DTTM%] Bye Bye World >> "%WD_LOGFILE%"

I put two files on the folder and I get the following log entries:
[C][20051124 013935] FILENEW R:\RTADEV10\VS\Statement_valuations\mail\VSSNV666666111.XML
[X][20051124 013935] Hello GdP world
[C][20051124 014935] FILENEW R:\RTADEV10\VS\Statement_valuations\mail\VSSNV7777777.XML
[X][20051124 014935] Hello GdP world

The above is on 2.5. (my client runs 3.2.7).  I will upgrade both to v4 and come back to you on the other questions. thanks again. Loz

Title: Re: Batch file - handling errors
Post by Gert on Nov 24th, 2005 at 5:44am
Can you add ECHO to the "fop" line, and see what happens?

ECHO C:\progra~1\....     >> "WD_LOGFILE%"

Gert

Title: Re: Batch file - handling errors
Post by Loz on Nov 24th, 2005 at 7:49pm
produces log entries of:

[X][20051124 194535] Hello GdP world

c:\progra~1\altova\fop\fop -xsl "R:\RTADEV10\VS\Statement_valuations\mail\bde2200t.xsl" -xml "R:\RTADEV10\VS\Statement_valuations\mail\VSSNV1188.XML" -pdf "R:\RTADEV10\VS\Statement_valuations\VSSNV1188.PDF"

[X][20051124 194535] Bye Bye World  

if I run this fop command off the command line, it does throw some errors and warnings, however the pdf still gets generated.

Has the batch file just hung or finished?

Ta

L.

Title: Re: Batch file - handling errors
Post by Gert on Nov 24th, 2005 at 8:00pm
As the "bye bye" lines normally don't get written, it looks like it is hanging.

Is this problem happening when you run "normal", or only when running as a service?
You are aware that you (normally) can not use mapped drive letters (should use UNC: \\server\share) when running as a service....

Just a stupid thought, at the start of your .bat copy/move the files to a local directory (c:\work) and process them there.

Gert

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.