Use ant to execute remote Linux scripts

Source: Internet
Author: User

1. Download jsch. Jar

Http://sourceforge.net/projects/jsch/files/jsch.jar/

 

2. Save the content and name it build. XML in the D:/anthome directory.

 

<Project name = "anthome" basedir = "../" default = "sshexec">
<Target name = "sshexec">
<Sshexec host = "172.10.10.89" username = "root" Password = "123456" Trust = "true" command = "CD/; ls"/>
</Target>
</Project>

 

3. Copy jsch. jar to D:/anthome.

4. Execute ant-lib D:/anthome

5. Display

 

Sshexec:
[Sshexec] connecting to 172.10.10.89: 22
[Sshexec] cmd: CD/; LS
[Sshexec] alfresco
[Sshexec] Bin
[Sshexec] boot
[Sshexec] cloudxfs
[Sshexec] Dev
[Sshexec] etc
[Sshexec] Home
[Sshexec] lib
[Sshexec] Media
[Sshexec] mnt
[Sshexec] Opt
[Sshexec] Proc
[Sshexec] root
[Sshexec] sbin
[Sshexec] Space
[Sshexec] srv
[Sshexec] sys
[Sshexec] TMP
[Sshexec] USR
[Sshexec] VaR

Build successful
Total time: 19 seconds
D:/anthome>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.