ant exec task trouble parsing quotes

R

rick bryant

all:

having trouble parsing quotes (") when running the ant exec target.
trying to build a goal in maven that executes an external pvcs command
to get a file from the pvcs repository. my exact goal looks like:
<goal name="gpc-pvcs-get">
<ant:exec executable="cmd.exe" path="d:/rbryant">
<ant:arg value="/c" />
<ant:arg value="cmdclient" />
<ant:arg value="-user ${pvcs.cmdclient.user}" />
<ant:arg value="-pass ${pvcs.cmdclient.pass}" />
<ant:arg value="-host ${pvcs.cmdclient.host}" />
<ant:arg value="-install ${pvcs.cmdclient.install}" />
<ant:arg value="-dbname ${pvcs.cmdclient.dbname}" />
<ant:arg value="-dbpass ${pvcs.cmdclient.dbpass}" />
<ant:arg value="-sqlnet ${pvcs.cmdclient.sqlnet}" />
<ant:arg value="-cmd ${pvcs.cmdclient.cmd}" />
</ant:exec>
</goal>

where:
pvcs.cmdclient.dbpass = \"\"
pvcs.cmdclient.cmd = \"FI GPC*EXP:A27991.A-SRC;bw49_3#1
/USER_FILENAME=d:\\downloads\\abyss\\AuthenticateUserForm.java\"

for some reason, the goal fails with a message that the pvcs
'cmdclient' command doesn't have all the required parameters and the
error that results is:
D:\rbryant>maven gpc-pvcs-get
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0-rc1-SNAPSHOT

gpc-pvcs-get:
[exec] Syntax: cmdclient [-user <id> -pass <password> -host
<server>
[exec] -install <directory> -dbname <database> -dbpass <password>
[exec] -sqlnet <identifier>] | [-param <parameter file>]
[exec] [-file <command file> | -cmd <Dimensions command>]
[exec] [-help] [-version] [-ascii | -binary]
[exec] [ERROR] Result: 1
BUILD SUCCESSFUL
Total time: 5 seconds
Finished at: Thu Nov 20 10:18:28 CST 2003

can execute the exact pvcs command from a dos shell without any
problems:
D:\downloads\abyss>cmd /c cmdclient -user rbryant -pass newguy -host
pvcshost1pc.internal.gxs.com -install /opt/pcms/dimensions7_1 -dbname
gpc_exp -dbpass "" -sqlnet pcms -cmd "FI GPC*EXP:A27991.A-SRC;bw49_3#1
/USER_FILENAME=d:\downloads\abyss\AuthenticateUserForm.java"
Operation completed

can also execute the exact pvcs command from a java class using the
exec() method from the Runtime class without any problems:
private void execute(){
String executable =
"cmd /c cmdclient -user rbryant -pass newguy -host
pvcshost1pc.internal.gxs.com -install /opt/pcms/dimensions7_1 -dbname
gpc_exp -dbpass \"\" -sqlnet pcms -cmd \"FI
GPC*EXP:A27991.A-SRC;bw49_3#1
/USER_FILENAME=d:\\downloads\\abyss\\AuthenticateUserForm.java\"";

Process process = null;
try{
process = Runtime.getRuntime().exec( executable );
}
catch( IOException ioe ) {
ioe.printStackTrace();
}
}

any ideas on how to get around the quote parsing problem in ant?

thanks very much,
rick
 
D

David Zimmerman

rick said:
all:

having trouble parsing quotes (") when running the ant exec target.
trying to build a goal in maven that executes an external pvcs command
to get a file from the pvcs repository. my exact goal looks like:
<goal name="gpc-pvcs-get">
<ant:exec executable="cmd.exe" path="d:/rbryant">
<ant:arg value="/c" />
<ant:arg value="cmdclient" />
<ant:arg value="-user ${pvcs.cmdclient.user}" />
<ant:arg value="-pass ${pvcs.cmdclient.pass}" />
<ant:arg value="-host ${pvcs.cmdclient.host}" />
<ant:arg value="-install ${pvcs.cmdclient.install}" />
<ant:arg value="-dbname ${pvcs.cmdclient.dbname}" />
<ant:arg value="-dbpass ${pvcs.cmdclient.dbpass}" />
<ant:arg value="-sqlnet ${pvcs.cmdclient.sqlnet}" />
<ant:arg value="-cmd ${pvcs.cmdclient.cmd}" />
</ant:exec>
</goal>

where:
pvcs.cmdclient.dbpass = \"\"
pvcs.cmdclient.cmd = \"FI GPC*EXP:A27991.A-SRC;bw49_3#1
/USER_FILENAME=d:\\downloads\\abyss\\AuthenticateUserForm.java\"

You probably want to use <arg line="..."/> instead of <arg value="..."/>
since value adds a single argument and line adds space delimented
arguments like what the shell command line would do.
 
J

John C. Bollinger

rick said:
all:

having trouble parsing quotes (") when running the ant exec target.
trying to build a goal in maven that executes an external pvcs command
to get a file from the pvcs repository. my exact goal looks like:
<goal name="gpc-pvcs-get">
<ant:exec executable="cmd.exe" path="d:/rbryant">
<ant:arg value="/c" />
<ant:arg value="cmdclient" />
<ant:arg value="-user ${pvcs.cmdclient.user}" />
<ant:arg value="-pass ${pvcs.cmdclient.pass}" />
<ant:arg value="-host ${pvcs.cmdclient.host}" />
<ant:arg value="-install ${pvcs.cmdclient.install}" />
<ant:arg value="-dbname ${pvcs.cmdclient.dbname}" />
<ant:arg value="-dbpass ${pvcs.cmdclient.dbpass}" />
<ant:arg value="-sqlnet ${pvcs.cmdclient.sqlnet}" />
<ant:arg value="-cmd ${pvcs.cmdclient.cmd}" />
</ant:exec>
</goal>

[...]

You could try debugging by inserting an "echo" as the command to run, to
see what the actual command line being used looks like. Chances are
that will lead you to a solution, or at least a better understanding of
the problem.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top