You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eric Fetzer <el...@yahoo.com> on 2009/08/05 19:10:36 UTC

sshexec

So sshexec is adding a carriage return to the outputproperty when run from winders.  Is there a way to strip this off of the end of a property in ant?  Here's a small repro:

test.sh:
<!--Begin Code Snip-->
echo "error" | tr '\n' '' | tr '\r' ''
exit 0
<!--End Code Snip-->

testSshExec.xml

<!--Begin Code Snip-->
<project default="main">

  <task name="main">
    <sshexec host="${ssh.host}"
      username="${ssh.user}"
      keyfile="${ssh.keyfile}"
      passphrase="${ssh.passphrase}"
      command="/home/myUser/test.sh"
      trust="true"
      timeout="1000"
      outputproperty="returnValue"
    />
  </task>

    <echo message="XXX${returnValue}XXX"/>

</project>
<!--End Code Snip-->


Run from winders machine, return is:

main:
  [sshexec] Connecting to myUnixBox:22
  [sshexec] error
     [echo] XXXerror
     [echo] XXX
BUILD SUCCESSFUL
Total time: 3 seconds

Thanks,
Eric


      

Re: sshexec

Posted by Eric Fetzer <el...@yahoo.com>.
No one cares?  Well if anyone decides to fix it, please let me know so that I can take my workaround out...




________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 1:54:08 PM
Subject: Re: sshexec

In order to fix this, I had to write a macrodef that strips the last character (no matter what it is being that you can't test for it):

  <macrodef name="stripLastChar" description="Drops the last char off of property value">
    <attribute name="my.property.name"/>
    <sequential>
      <length string="${@{my.property.name}}" property="length.prop" />
      <math result="length.prop" operand1="${length.prop}" operation="-" operand2="1" datatype="int"/>
      <propertyregex property="@{my.property.name}" override="true" input="${@{my.property.name}}" regexp="^.*{${length.prop},${length.prop}}" select="\0"/>
    </sequential>
  </macrodef>

I would consider the behavior of sshexec a bug.  Anyone else...



________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 12:19:13 PM
Subject: Re: sshexec

I tried:

    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\r" replace=""
    />
    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\n" replace=""
    />

But it doesn't seem to work on newline/cr stuff...  This is nuts, is what I'm trying to do really all that tough?




________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 11:10:36 AM
Subject: sshexec

So sshexec is adding a carriage return to the outputproperty when run from winders.  Is there a way to strip this off of the end of a property in ant?  Here's a small repro:

test.sh:
<!--Begin Code Snip-->
echo "error" | tr '\n' '' | tr '\r' ''
exit 0
<!--End Code Snip-->

testSshExec.xml

<!--Begin Code Snip-->
<project default="main">

  <task name="main">
    <sshexec host="${ssh.host}"
      username="${ssh.user}"
      keyfile="${ssh.keyfile}"
      passphrase="${ssh.passphrase}"
      command="/home/myUser/test.sh"
      trust="true"
      timeout="1000"
      outputproperty="returnValue"
    />
  </task>

    <echo message="XXX${returnValue}XXX"/>

</project>
<!--End Code Snip-->


Run from winders machine, return is:

main:
  [sshexec] Connecting to myUnixBox:22
  [sshexec] error
     [echo] XXXerror
     [echo] XXX
BUILD SUCCESSFUL
Total time: 3 seconds

Thanks,
Eric


      

Re: sshexec

Posted by Eric Fetzer <el...@yahoo.com>.
In order to fix this, I had to write a macrodef that strips the last character (no matter what it is being that you can't test for it):

  <macrodef name="stripLastChar" description="Drops the last char off of property value">
    <attribute name="my.property.name"/>
    <sequential>
      <length string="${@{my.property.name}}" property="length.prop" />
      <math result="length.prop" operand1="${length.prop}" operation="-" operand2="1" datatype="int"/>
      <propertyregex property="@{my.property.name}" override="true" input="${@{my.property.name}}" regexp="^.*{${length.prop},${length.prop}}" select="\0"/>
    </sequential>
  </macrodef>

I would consider the behavior of sshexec a bug.  Anyone else...



________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 12:19:13 PM
Subject: Re: sshexec

I tried:

    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\r" replace=""
    />
    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\n" replace=""
    />

But it doesn't seem to work on newline/cr stuff...  This is nuts, is what I'm trying to do really all that tough?




________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 11:10:36 AM
Subject: sshexec

So sshexec is adding a carriage return to the outputproperty when run from winders.  Is there a way to strip this off of the end of a property in ant?  Here's a small repro:

test.sh:
<!--Begin Code Snip-->
echo "error" | tr '\n' '' | tr '\r' ''
exit 0
<!--End Code Snip-->

testSshExec.xml

<!--Begin Code Snip-->
<project default="main">

  <task name="main">
    <sshexec host="${ssh.host}"
      username="${ssh.user}"
      keyfile="${ssh.keyfile}"
      passphrase="${ssh.passphrase}"
      command="/home/myUser/test.sh"
      trust="true"
      timeout="1000"
      outputproperty="returnValue"
    />
  </task>

    <echo message="XXX${returnValue}XXX"/>

</project>
<!--End Code Snip-->


Run from winders machine, return is:

main:
  [sshexec] Connecting to myUnixBox:22
  [sshexec] error
     [echo] XXXerror
     [echo] XXX
BUILD SUCCESSFUL
Total time: 3 seconds

Thanks,
Eric


      

Re: sshexec

Posted by Eric Fetzer <el...@yahoo.com>.
I tried:

    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\r" replace=""
    />
    <propertyregex property="my.property"
      override="true" 
      input="${my.property}" 
      regexp="\n" replace=""
    />

But it doesn't seem to work on newline/cr stuff...  This is nuts, is what I'm trying to do really all that tough?




________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users <us...@ant.apache.org>
Sent: Wednesday, August 5, 2009 11:10:36 AM
Subject: sshexec

So sshexec is adding a carriage return to the outputproperty when run from winders.  Is there a way to strip this off of the end of a property in ant?  Here's a small repro:

test.sh:
<!--Begin Code Snip-->
echo "error" | tr '\n' '' | tr '\r' ''
exit 0
<!--End Code Snip-->

testSshExec.xml

<!--Begin Code Snip-->
<project default="main">

  <task name="main">
    <sshexec host="${ssh.host}"
      username="${ssh.user}"
      keyfile="${ssh.keyfile}"
      passphrase="${ssh.passphrase}"
      command="/home/myUser/test.sh"
      trust="true"
      timeout="1000"
      outputproperty="returnValue"
    />
  </task>

    <echo message="XXX${returnValue}XXX"/>

</project>
<!--End Code Snip-->


Run from winders machine, return is:

main:
  [sshexec] Connecting to myUnixBox:22
  [sshexec] error
     [echo] XXXerror
     [echo] XXX
BUILD SUCCESSFUL
Total time: 3 seconds

Thanks,
Eric