0

I have a problem in passing a string containing a dollar sign to ant script.

In tclist text file,

org.apache.jmeter.gui.action.Load$Test  testFile3

In bash script,

while read tcls tmethod
do

    echo ${tcls},${tmethod}
    ant -Dtcls="$tcls" -Dtmethods="$tmethod"

done < $tclist

In ant script,

<echo message="Run ${tcls}, ${tmethods}."/>
<junit haltonerror="false" haltonfailure="false" printsummary="true" fork="true">
    <test name="${tcls}" todir="${result.junit.dir}" methods="${tmethods}"/>
</junit>

bash echo message,

org.apache.jmeter.gui.action.Load$Test,testFile3

ant echo message,

[echo] Run org.apache.jmeter.gui.action.Load, testFile3.

The echo message shows that substring after the dollar sign disappears... I'm stuck in this problem for hours. Is there any way to print the whole string?

Update: A temporary remedy... I couldn't find a reason for this, but I solved the problem. I add "/" after "$" in tclist not to be removed in the ant script. Next, I use a sed expression in the ant script to replace "$/" with "$". A comment from here(https://stackoverflow.com/a/6151678/1900548) helps me come up with this idea. If anyone knows the exact reason for this problem, please let me know. Thanks.

In tclist text file,

org.apache.jmeter.gui.action.Load$/Test testFile3

In ant script,

<exec executable="sed" inputstring="${tcls}" outputproperty="tcls_after">
    <arg value="s/$\//$/g"/>
</exec>

<echo message="Run ${tcls_after}, ${tmethods}."/>

ant echo message,

[echo] Run org.apache.jmeter.gui.action.Load$Test, testFile3.
Community
  • 1
  • 1
Jung-Hyun
  • 233
  • 5
  • 14
  • Try putting "echo $tcls" in your loop between "do" and "ant" to see if your "read" statement is working. – Mark Setchell Apr 12 '14 at 14:38
  • @MarkSetchell Thanks for comment. I added bash echo message. It seems that bash echo is working correctly... – Jung-Hyun Apr 13 '14 at 04:04
  • I think the bash script is trying to substitute a value for $Test eventhough the value was quoted. If you set variable value for Test, then run and see if that value gets appended to end of ...Load – mikemil Apr 13 '14 at 04:22

0 Answers0