Bat-files of a distributed programm don't allow arguments(directories)

Status
Not open for further replies.
G

Guest

Guest
Hi,
---------------------------------------------------------------------------------------------------
If you could help me it would be highly appreciated since I should use the result to

continue my project i've to present wednesday!
Furthermore, I've no knowlegde about .bat-files at all...

----------------------------------------------------------------------------------------------------

CONTEXT OF THE PROBLEM:
I'm calling the programm treetagger
(Treetagger) automatically in a perlscript via the corresponding .bat-files (corresponding to the language of the text: example: tag-english.bat) distributed togheter with treetagger! The arguments of these .bat-files are directories. If the directories passed as arguement do not include spaces, it works perfectly fine. However if they do include spaces - what is crucial in my project -, there appears an error-message saying that the second word of the argument "cannot be processed at this place".


PROBLEM:
These .bat files (example tag-english.bat at the end) do not correctly process arguments with spaces.
-How do I solve that?


PRECISE LOCALISATION OF THE PROBLEM (simple case: assume only one argument %1):
In the .bat-files, in the command:

perl %CMD%\tokenize.pl -e -a %LIB%\english-abbreviations %1 | %BIN%\tree-tagger %TAGOPT%

=> There is a SYNTAXICAL ERROR in this line when the argument %1 contains spaces (The perl-script tokenize.pl is never started, I tested.).
SO THERE IS NO NEED TO HAVE TREETAGGER (OR TOKENIZE.PL) INSTALLED TO FIND THE ERROR!:)


SOLUTIONS TRIED:
I tried different things refering to
this
but since I have no background about windows bat-files it's just try an error...
By the way I use Windows XP, but the solution should work for any windows if possible!:)


Any help would be highly appreciated!!!!

Best regards,

Sam


----------------------------------------------------------------------------------------------------
example tag-english.bat:

@echo off

set TAGDIR=C:\Programme\TreeTagger

set BIN=%TAGDIR%\bin
set CMD=%TAGDIR%\cmd
set LIB=%TAGDIR%\lib
set TAGOPT=%LIB%\english.par -token -lemma -sgml -no-unknown -cap-heuristics

-hyphen-heuristics

if "%2"=="" goto label1
perl %CMD%\tokenize.pl -e -a %LIB%\english-abbreviations %1 | %BIN%\tree-tagger %TAGOPT% >

%2
goto end

:label1
if "%1"=="" goto label2
perl %CMD%\tokenize.pl -e -a %LIB%\english-abbreviations %1 | %BIN%\tree-tagger %TAGOPT%
goto end

:label2
echo.
echo Usage: tag-english file {file}
echo.

:end
----------------------------------------------------------------------------------------------------
 

Zenthar

Distinguished
Glad you could figure-it out.

BTW, spaces are always a pain in any "shell" scripting, the same double-quote thing applies in Linux as well (for your personal knowledge). As a personal "rule", I try to always enclose parameters and even environment variables in double-quotes to make sure an environment difference don't screw me up. For example if someone was to call the following command
Code:
perl %CMD%\tokenize.pl
If CMD was "C:\Program files\MySoft", it would blow-up, you should write it as:
Code:
perl "%CMD%\tokenize.pl"
 
Status
Not open for further replies.