You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Maneesh Sahu <ms...@interkeel.com> on 2001/07/25 03:01:22 UTC

Quotes in the commandline and the ExecTask

Folks,
I have been trying to pass a commandline arg containing quotes"", but it
seems to get stripped when its actually executed.

My log.xml shows string containing the String just prior to execution and
when the execute() is called on the ExecTask. Note the text following -cp...

			<message priority="debug"><![CDATA[EJB Deploy Options:
D:\workdir\ant\build\ejb\AuthInfo-generic.jar _ejb_temp
D:\workdir\ant\build\ejb\AuthInfo.jar  -cp
"E:\IBM\WAS40\lib\j2ee.jar;E:\IBM\WAS40\lib\websphere.jar;D:\workdir\ant\bui
ld\classes"  -dbvendor ORACLE_V8 -quiet]]></message>
			<message priority="debug"><![CDATA[ejbdeploy.bat
D:\workdir\ant\build\ejb\AuthInfo-generic.jar _ejb_temp
D:\workdir\ant\build\ejb\AuthInfo.jar -cp
E:\IBM\WAS40\lib\j2ee.jar;E:\IBM\WAS40\lib\websphere.jar;D:\workdir\ant\buil
d\classes -dbvendor ORACLE_V8 -quiet]]></message>

The absence of the quote causes a command execution problem.

Any escape characters that I can utilize for the quotes?
Any pointers in this direction...
TiA
--Maneesh


RE: Quotes in the commandline and the ExecTask

Posted by Maneesh Sahu <ms...@interkeel.com>.
Stefan,

I was browsing the code of Commandline.Argument and noticed that there was
indeed code to strip the quotes while reading the arguments and then
re-insert them only if the argument within quotes contained a whitespace.

I worked around this problem by forcing a space within the quotes. This work
around will work just as long as no-one does a trim() on the argument!

--maneesh

-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org]
Sent: Wednesday, July 25, 2001 1:53 AM
To: ant-dev@jakarta.apache.org
Subject: Re: Quotes in the commandline and the ExecTask


On Tue, 24 Jul 2001, Maneesh Sahu <ms...@interkeel.com> wrote:

> Folks, I have been trying to pass a commandline arg containing
> quotes"", but it seems to get stripped when its actually executed.

I wouldn't trust <exec>'s logging, the task only sends an
approximation of what really gets executed to the logging system.
What you see is what would be used for Runtime.exec(String), but Ant
uses Runtime.exec(String[]) internally and the result may very well be
different.

Could you send a relevant snippet of your build file so we can have a
look at it, please?

Stefan


Re: Quotes in the commandline and the ExecTask

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 24 Jul 2001, Maneesh Sahu <ms...@interkeel.com> wrote:

> Folks, I have been trying to pass a commandline arg containing
> quotes"", but it seems to get stripped when its actually executed.

I wouldn't trust <exec>'s logging, the task only sends an
approximation of what really gets executed to the logging system.
What you see is what would be used for Runtime.exec(String), but Ant
uses Runtime.exec(String[]) internally and the result may very well be
different.

Could you send a relevant snippet of your build file so we can have a
look at it, please?

Stefan