Bug 35532 - sshexec task can't issue multiple commands easily.
Summary: sshexec task can't issue multiple commands easily.
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.6.5
Hardware: All Windows 2000
: P2 enhancement with 3 votes (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-28 23:31 UTC by Andrzej Taramina
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
Sample code for SSHExecMultiple (9.98 KB, text/plain)
2005-06-28 23:32 UTC, Andrzej Taramina
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrzej Taramina 2005-06-28 23:31:52 UTC
You can separate the commands using a command line separator, but with many such
commands, it's difficult to read the resulting ant task.

I've added an extension that lets you nest <command> subelements to the sshexec
task, which cleans up this process.  New class is called SSHExecMultiple for
this task.

...Andrzej
Comment 1 Andrzej Taramina 2005-06-28 23:32:31 UTC
Created attachment 15549 [details]
Sample code for SSHExecMultiple
Comment 2 Andrzej Taramina 2005-06-28 23:51:50 UTC
Sample usage for testing of sshexecmultiple:

<target name="test-sshmultiple">
   <echo>Starting sshexecmultiple test...</echo>
		
   <!-- sshexecmultiple lets you nest multiple commands and will 
        execute them in sequence.
		
	Attributes are the same as for the base sshexec, with the addition of 
        the haltonerror attribute.
	If haltonerror = "true" then if any command fails, subsequent commands 
        will not be executed.
	If haltonerror = "false" then if any command fails, subsequent commands 
        will STILL be executed.
		
	NOTE: The state is not preserved between the commands in this version. 
	For example, if you change dirs in one command, this will no longer be 
        in effect for the subsequent commands,
	as is demonstrated below.  If you need to change state (ie directory) 
        use semi-colons to separate multiple
	commands in a single <command> entry as is demonstrated below.
   -->
		
   <sshexecmultiple host="myhost" 
      username="user" 
      keyfile="mykeyfile" 
      passphrase="lemmein"
      trust="true"
      haltonerror="false">
      <command>echo One</command>
      <command>xyz</command>
      <command>echo Two</command>
      <command>pwd</command>
      <command>cd ..;pwd</command>
      <command>pwd</command>
   </sshexecmultiple>

   <echo>Done sshexecmultiple test</echo>
</target>
Comment 3 Kev Jackson 2007-09-10 00:30:34 UTC
-fixed in svn head using a FileResource, specify your commands in a seperate file eg.

build.xml
<sshexec host="ip" port="22"
 			username="root" password=""
 			commandResource="my-commands"
 			failonerror="true" trust="true"/>

my-commands: 			
touch 1.txt
mv 1.txt 2.txt
mv 2.txt 3.txt