Christoph

While my response is late, and you seemed to have solved your problem, if you 
don't mind, I would like to attempt to clarify about quotes and spaces in 
Windows.

-----Original Message-----
From: Christoph P.U. Kukulies [mailto:k...@kukulies.org] 
Sent: Wednesday, January 10, 2018 6:39 AM
To: users@tomcat.apache.org
Subject: Re: tomcat 7.0 resurrecting directory while service is installed - 
running in command line mode?

[SNIP]

> Nonetheless still having a bit trouble with it and would like
> to use your suggestion, but it fails somehow due to blanks in
> path name. This weirdness with blanks in paths:
>
> C:\Program Files\Apache Software Foundation\Tomcat 7.0>SET 
> CATALINA_HOME=c:"\Program Files\Apache Software Foundation\Tomcat 7.0"
>
> C:\Program Files\Apache Software Foundation\Tomcat 7.0>echo %CATALINA_HOME%
> c:"\Program Files\Apache Software Foundation\Tomcat 7.0"

> C:\Program Files\Apache Software Foundation\Tomcat 
> 7.0>%CATALINA_HOME%\bin\catalina.bat start
> "Files\Apache" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
>
> C:\Program Files\Apache Software Foundation\Tomcat 7.0>
>
> I tried various combinations of quoting. Does anyone see the error?

You don't need quotes using SET statements in Windows Command Prompt (aka, 
batch files).  Everything after the equals sign is assigned to the variable.  
(Um, except for maybe output redirects such as greater than, but please don't 
quote me on that.)  So these below are fine:

SET CATALINA_HOME=C:\Program Files\Apache Software Foundation\Tomcat 7.0

SET CATALINA_HOME=%ProgramFiles%\Apache Software Foundation\Tomcat 7.0

Where the quotes are needed would be when the variable is evaluated in an 
expression %LIKE_THIS% for commands that separate command line tokens using 
spaces.  The DIR command is sensitive to spaces because it can take multiple 
args on its command line.

Without the quotes DIR is confused:

> DIR %ProgramFiles%
>
> File Not Found

With the quotes DIR works fine:

> DIR "%ProgramFiles%"
>
> Directory of C:\Program Files

Here's the iffy part.  I used only one set of quotes around an entire argument. 
 I have found that using multiple sets of quotes around each space-embedded 
section at the very least confuses the human (me) and *sometimes possibly* the 
computer, especially when nesting of batch files occurs, but I have not 
definitively proved this.  So I try to keep it simpler by using the least 
amount of quotes possible when wrapping each whole argument individually.

Multiple quotes is confusing to me but works with DIR:

> DIR C:\"Program Files"\"Common Files"
>
> Directory of C:\Program Files\Common Files

Single set of double-quotes is less confusing for me:

> DIR "C:\Program Files\Common Files"
>
> Directory of C:\Program Files\Common Files

Examples of nested batch files with space-embedded arguments and multiple sets 
of quotes are beyond the scope of this example and are left as an exercise to 
the reader.  ;-)

And to top it off, I sometimes "cheat" by changing the installation folder 
names to remove spaces so I don't have to mess with quotes:

> C:\apps\asf\tomcat_7.0

FYI, these findings have been from personal experience, not from any official 
documentation.  So the caveat YMMV might still apply.

Hope this helps to make things at least a little bit less confusing.  :-)

--
Cris Berneburg
CACI Lead Software Engineer

Reply via email to