Bug 49429 - sshexec should have option to stripLastCharacter
Summary: sshexec should have option to stripLastCharacter
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.2
Hardware: PC Windows NT
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2010-06-11 12:30 UTC by pietari
Modified: 2010-12-27 11:12 UTC (History)
0 users



Attachments
Ant 1.8.1 SSHExec.java, modified to include new parameter StripLastCharacter (14.21 KB, application/octet-stream)
2010-06-11 12:30 UTC, pietari
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pietari 2010-06-11 12:30:51 UTC
Created attachment 25589 [details]
Ant 1.8.1 SSHExec.java, modified to include new parameter StripLastCharacter

As described on the ant users list in August 2009,

http://old.nabble.com/sshexec-td24832653.html

output from sshexec includes a newline at the end.

This creates difficulties when the output is intended for later use. To give an example, I have an Ant build that needs to find a process ID. I do this with the sshexec task by executing:

ps -ef | grep -v grep | grep ${mysearchstring} | awk '{ print $2 }'

This gives me a process ID, but also a newline at the end, which I must then remove using a stripLastChar macrodef.

It would be far more convenient if there was an option in the sshexec task to strip this last character out of the output.

Attached is a version of SSHExec.java, created by modifying Ant 1.8.1, which has this parameter and strips the last character out as required. Maybe you could consider this for inclusion in the next release of Ant?
Comment 1 Stefan Bodewig 2010-06-15 08:39:16 UTC
it would probably be more useful and more general if the task supported a nested
redirector like <exec> does.  This way you could plug in your own filterchain
and could even do away with your "grep"s.