• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2519
  • Last Modified:

More Batch File Problems

This is on Xp if it is relevant and is a continuation of my previous question. This script hits the error catch even with a file of 3,283,729 bytes:

@echo off
echo\

echo Changing Directory
cd /d %2

del %TEMP\chmbuild\*

CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2

echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.language ja --stringparam htmlhelp.use.hhk 1 --output %TEMP%\chmbuild\ "%DOCBOOK_BASE%\xsl\htmlhelp\mysql-html-help.xsl" "%TEMP%\chmbuild\%1.xml"
if not %errorlevel%==0 goto :ERROR

echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.hhp
if not %errorlevel%==0 goto :ERROR

echo Checking File Size
pushd.

cd /D "%TEMP%\chmbuild"

set error=

for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do if /I %%~za LSS 2000000 set error=Y

popd

if "%error%"=="Y" goto :ERROR

echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.chm C:\built-docs\%1-%3.chm
if not %errorlevel%==0 goto :ERROR

goto :EXIT

:ERROR
echo ERROR ENCOUNTERED
exit /B -1

:EXIT
exit /B 0
0
Squeebee
Asked:
Squeebee
  • 4
  • 2
1 Solution
 
SteveGTRCommented:
Could it be there is an error from another portion of your script?

I ran a test of this code that simulates the file size error processing in your code:

@echo off

set error=

for /f "delims=" %%a in ('dir /b "%~1"') do echo if /I %%~za LSS 2000000 set error=Y
for /f "delims=" %%a in ('dir /b "%~1"') do if /I %%~za LSS 2000000 set error=Y

if "%error%"=="Y" echo Error

I ran it against some huge database backup files and it didn't report an error:

05/03/2006  02:52 PM       828,255,744 PMC_20060502_NOREPL.bak

Can you run the test against the file you have the problem with? The batch file accepts the file name and you should run it from the directory where the file exists (cd /D "%TEMP%\chmbuild").

My reference to the "other" error processing deals with the move code:

echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.chm C:\built-docs\%1-%3.chm
if not %errorlevel%==0 goto :ERROR

Could that be failing? You'd see the "Moving from Temp Directory" message.
0
 
SqueebeeAuthor Commented:
I do not see the moving message. I've tried replacing the if with an echo to see what size is reported. Will let you know.
0
 
SqueebeeAuthor Commented:
This script results in no size value echoed at all.

@echo off
echo\

echo Changing Directory
cd /d %2

del %TEMP\chmbuild\*

CALL prepare_xml.bat %1 %2
CALL strip_remarks.bat %1 %2

echo Building Intermediate Files
xsltproc --xinclude --stringparam l10n.gentext.default.language ja --stringparam htmlhelp.use.hhk 1 --output %TEMP%\chmbuild\ "%DOCBOOK_BASE%\xsl\htmlhelp\mysql-html-help.xsl" "%TEMP%\chmbuild\%1.xml"
if not %errorlevel%==0 goto :ERROR

echo Compiling HTML Help File
hhc.exe %TEMP%\chmbuild\htmlhelp.hhp
if not %errorlevel%==0 goto :ERROR

echo Checking File Size
pushd.

cd /D "%TEMP%\chmbuild"

set error=

for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do echo %%~za

popd

if "%error%"=="Y" goto :ERROR

echo Moving from Temp Directory
move %TEMP%\chmbuild\htmlhelp.chm C:\built-docs\%1-%3.chm
if not %errorlevel%==0 goto :ERROR

goto :EXIT

:ERROR
echo ERROR ENCOUNTERED
exit /B -1

:EXIT
exit /B 0
0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
SqueebeeAuthor Commented:
And yet I get ERROR ENCOUNTERED:

Created c:\DOCUME~1\XPBox\LOCALS~1\Temp\chmbuild\htmlhelp.chm, 3,283,731 bytes
Compression decreased file by 8,088,571 bytes.
ERROR ENCOUNTERED
Building 5.0 CHM ...
0
 
SteveGTRCommented:
Sounds like the htmlhelp.chm file doesn't exist in "%TEMP%\chmbuild" at the time of the for statement. How about doing this before the for statement:

if exist "htmlhelp.chm" echo File htmlhelp.chm exists in %cd%
if not exist "htmlhelp.chm" echo File htmlhelp.chm does not exist in %cd%

for /f "delims=" %%a in ('dir /b htmlhelp.chm 2^>NUL') do echo %%~za

...
0
 
SqueebeeAuthor Commented:
Found it, it was the errorlevel check after the call to hhc.exe. The foolish thing returns 1 upon a successful compile instead of 0. I want to beat someone.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now