Ant task to remotely delete a directory
Is there a way except the sshexec
task to do this? I know that you can copy files with the scp
task. However, I need to do additional things like check if some folders are there then delete them. I would like to use something like the condition
task and delete
task for this. For now I have set it up with t开发者_运维百科he sshexec
task. But this will most likely not work on a Windows server. And to do something like check if a directory is there and delete it I would have to write a script instead using ant tasks (for now I expect that the directory which should be deleted is actually there which I don't like because when it's missing my sshexec
task will interrupt). Thanks in advance for any help.
Yes: you can use sshexec. The documentation describes how to do it: http://ant.apache.org/manual/Tasks/sshexec.html
For example:
<sshexec host="somehost"
username="dude"
password="yo"
command="touch somefile"/>
You can use the 'command' attribute to call a shell script on the remote host that will do your checks and deletes as I'm not sure if you can have multiple commands in the command attribute, plus it would get a bit messy that way.
精彩评论