Ant sshexec command not found

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

 像这样:

 

Xml代码   收藏代码
  1. <sshexec trust="true" host="youhost" username="username" password="password" command="source ~/.bash_profile ; [your command here]" failonerror="false" />  
 

猜你喜欢

转载自northc.iteye.com/blog/1517368