maven - mvn exec :exec with '<' in commandlineArgs

标签 maven ssh putty plink

我需要运行一个包含“<”的命令。

我可以从命令行运行它,但是当我将它放入 mvn exec 时它会抛出错误。

命令:

c:\apps\putty\plink.exe myuser@myhost -T -ssh -2 $SHELL /dev/stdin 'a b c d' < test.sh

测试.sh:
#!/bin/bash
echo "execution parameters: $@"

命令行输出:

execution parameters: a b c d



pom.xml:
<plugin> 
                <groupId>org.codehaus.mojo</groupId> 
                <artifactId>exec-maven-plugin</artifactId> 
                <version>1.4.0</version> 
                <executions> 
                    <execution>
                        <id>test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration><executable>c:\apps\putty\plink.exe</executable>
                            <commandlineArgs>"myuser@myhost -T -ssh -2 $SHELL /dev/stdin 'a b c d' < test.sh"</commandlineArgs>
                        </configuration>
                    </execution>
            </executions> 
        </plugin> 

我尝试将“<”更改为“<”,将 commandlineArgs 放入 CDATA,将 doubleqoutes (") 置于任何地方,但无法使其正常工作。
[DEBUG] Executing command line: [c:\apps\putty\plink.exe, > myuser@myhost -T -ssh -2 -pw tomcat  $SHELL /dev/stdin 'a b c d' &lt; test.sh] 
Unable to open connection: Host does not exist[INFO]
------------------------------------------------------------------------ 
[INFO] BUILD FAILURE

或者:
[DEBUG] Executing command line: [c:\apps\putty\plink.exe, myuser@myhost, -T, -ssh, -2, -pw, tomcat, $SHELL /dev /stdin 'a b c d' &lt; test.sh] 
bash: test.sh: No such file or directory [INFO]
------------------------------------------------------------------------ 
[INFO] BUILD FAILURE

我怀疑 '<' 参数,但我不确定真正的问题是什么。

有小费吗?

更新:当我说“”时,我尝试将“<”更改为“<”,将 commandlineArgs 放入 CDATA,将 doubleqoutes (") 放在任何地方,但无法使其正常工作。 “- 我是认真的!

最佳答案

如果我将它包装在 .bat 文件中,它就可以工作:

@echo off
set plinkExec=%1
set env=%2
set user=%3
set pass=%4
set shellPath=%5
...

%plinkExec% %user%@%env% -T -ssh -2 -pw %pass% $SHELL /dev/stdin '...' < %shellPath%

不太好,但有魔力:-)

关于maven - mvn exec :exec with '<' in commandlineArgs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35430716/

相关文章:

java - Maven 在 Jenkins 中构建失败,在命令行上成功

ssh - SSH错误:权限被拒绝,请重试

c - 漂亮的树打印屏幕限制

connection - PuTTy 错误 : Unable to open connection, 网络错误无效参数

java - Maven-如何找到负责我当前项目正在使用的 jar 文件的组 ID?

Java Maven WebApp Tomcat

maven - 无论 Maven 生命周期如何,如何合并 2 个 jacoco 覆盖率报告(.exec 文件)

windows - 在 Windows 上为 Bitbucket 设置 SSH key

mercurial - 推送到远程 Mercurial 存储库

ssh - 谷歌云 SSH key