简体   繁体   中英

Ant properties with special characters

Am trying to pass Password and username as arguments to my ant file connectionTester.xml.. Am running the ant with -v and -d options. What I see as getting changed in the property irks me too much and am not able to find the solution. The password contains $ character which when followed with a character that forms a linux command gets replaced as you see in the verbose output below.

How to handle this scenario. The password gets trucated or replaced with something else and eventually the build fails.

[u@VM:h W]$ /opt/app/apache-ant-1.9.2/bin/ant -file connectionTester.xml -DdeployServer_user=xxxxxxx -DdeployServer.password=apr20$1 -v -d
Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Buildfile: /home/xxxxxx/connectionTester.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.7 in: /usr/java/jdk1.7.0_25/jre
Detected OS: Linux
Adding reference: ant.ComponentHelper
Setting ro project property: deployServer_user -> xx49783
Setting ro project property: deployServer.password -> apr20-file
Setting ro project property: ant.file -> /home/xx49663/connectionTester.xml
Setting ro project property: ant.file.type -> file

Try with setting password in command line prior to ant call & escaping the meaning of $ ( considering it is passed as plain text in command line ) like in command line

$myPass=apr20\$1

and then with

-DdeployServer.password=$myPass

尝试像

-DdeployServer.password='apr20\$1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM