ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: Question re sshexec task
Date Mon, 19 Dec 2005 09:25:38 GMT
 
Hi, Rhino

-----Original Message-----
From: Rhino [mailto:rhino1@sympatico.ca] 
Sent: Sunday, December 18, 2005 3:30 PM
To: Ant Users List
Subject: Re: Question re sshexec task

/*
Could you possibly post a small example of the technique you're using?
I'm 
not sure how to combine exec with ssh/scp. You can disguise the server
name, 
user id, passphrase and so forth. The example doesn't need to do
anything 
fancy; a simple 'pwd' and 'mkdir' would be fine.

It would really help me revise my script so that it works again!
*/

I suppose you want to work on a unix box, as i do ?!
On a windows box you could use the free putty client, which has also
a command line interface.

What i did before writing the script =

i went to our unix admins and said i want to use ssh/scp without
password,
so my script runs without hardcoded passwords or any kind of interaction
(prompts for password).

they had to fiddle in the /home/.ssh directory,
your unix admins should know what to do ;-)

My script transfers all stuff to one unix machine and does
all the rest - copy and delete on other unix machines -
via scp / ssh

here's a part of a script using ssh / scp =

[ ... ]

<assert name="deletelist.@{Lum}" execute="true">
	<for list="${deletelist.@{Lum}}" param="delfile">
	<sequential>
	<echo message="Deleting File ->
${target}/@{Lum}/opt/andromeda@{delfile}" />

*** Kornshell ksh , you may have another shell on your box
	<exec executable="ksh" failonerror="true">

*** rm
     with Flag -r you're able delete files _and_ directories(even if not
empty)
     with Flag -f you don't get any error messages, i.e. when the file
doesn't
     exist on one of the nodes
     with Flag -e you get a message on stdout when a file is deleted
     
*** ssh
     you have to put the whole line between ' ' and the rm command
between " "
     just use your commands, i.e. pwd or mkdir in the same manner

		<arg value='ssh @{server} "rm -r -f -e
${target}/@{Lum}/opt/andromeda@{delfile}"'/>
	</exec>
	</sequential>
	</for>
</assert>

<assert name="updatelist.@{Lum}" execute="true">
	<for list="${updatelist.@{Lum}}" param="copyfile">
	<sequential>
	<echo message="Copy File -> @{copyfile}" />
	<exec executable="ksh" failonerror="true">

*** scp
     with Flag -p the timestamps are preserved
     with Flag -r you may copy files _and_ directories

*** the syntax with the 5 '@' has to be written that way because of
    using ant-contrib for task

*** normally there's no linefeed after ${target}/ in my script

		<arg value="scp -p -r ./@{Lum}/serverdata@{copyfile}
svcscmcs@@@@@{server}:${target}/@{Lum}/opt/andromeda@{copyfile}" />
	</exec>
	</sequential>
	</for>
</assert>
[ ... ]


HTH

Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message