---
title: "Ant sshexec command not found"
author: "northc"
date: "2012-05-08T14:06:40Z"
tags: []
categories: ["开源软件"]
slug: "ant-sshexec-command-not-found"
draft: false
lastmod: "2012-05-08T14:06:40Z"
id: 1517368
url: "https://northc.iteye.com/blog/1517368"
---

使用ant的sshexec插件可以方便的用ssh在远程机器上执行命令行，但某些时候你可能会遇到这样的问题，同样的命令使用ssh客户端连过去再运行就没有问题，但在ant里面运行，就蹦出来   
command not found字样的错误，其原因就在，ant的sshexec连过去的时候，是不会执行～/.bash\_profile的，于是在你这个会话当中，自然就有可能找不到某些Command了，简单的解决办法就是在你要执行的命令前面加上这句source ~/.bash\_profile

 像这样：

 

Xml代码  [![收藏代码](http://tomorrow009.iteye.com/images/icon_star.png)](http://tomorrow009.iteye.com/blog/1156178 "收藏这段代码")

1. &lt;sshexec trust="true" host="youhost" username="username" password="password" command="source ~/.bash\_profile ; \[your command here]" failonerror="false" /&gt;