如何解决ANT sshexec命令
我正在bw脚本中使用sshexec来检查远程服务器上是否存在文件,但是output属性似乎有另外一行。
试图添加'sed -r'/ ^ \ s * $ / d',但这似乎也无济于事。
<sshexec trust="true"
host="${Deploy.remote_hostname}"
username="${Deploy.username}"
verbose="true"
password="${Deploy.password}"
command="test -f ${Deploy.remote_propfile_loc}${Deploy.application_name}_${Deploy.application_version}_@{currentappspace}_@{currentappnode}.substvar && echo 'true'||echo 'false' | sed -r '/^\s*$/d';"
failonerror="true"
outputproperty="file.exists"/>
<echo>this is file "${file.exists}" "Deploy.true"</echo>
cmd : test -f /home/tibco/jenkins/BW_DEV_Login/concatName.application_1.0_AS1_AS1_AN1.substvar && echo 'true'||echo 'false' | sed -r '/^\s*$/d';
true
Disconnecting from dewaserv7377.smartgrid.local port 22
Caught an exception,leaving main loop due to Socket closed
this is file "true
" "Deploy.true"
解决方法
对于这种情况,我建议使用Ant的sshsession
任务在远程计算机上运行本机Ant任务,而不是使用sshexec
嵌入复杂的shell命令。
<property
name="file.name"
value="${Deploy.remote_propfile_loc}${Deploy.application_name}_${Deploy.application_version}_@{currentappspace}_@{currentappnode}.substvar"
/>
<sshsession
trust="true"
host="${Deploy.remote_hostname}"
username="${Deploy.username}"
password="${Deploy.password}"
failonerror="true"
>
<condition property="file.exists" value="true" else="false">
<available file="${file.name}" />
</condition>
</sshsession>
<echo>this is file "${file.exists}" "Deploy.true"</echo>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。