【发布时间】:2017-04-10 08:48:47
【问题描述】:
我需要运行一个包含“
我可以从命令行运行它,但是当我将它放入 mvn exec 时会引发错误。
命令:
c:\apps\putty\plink.exe myuser@myhost -T -ssh -2 $SHELL /dev/stdin 'a b c d' < test.sh
test.sh:
#!/bin/bash
echo "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>
我尝试将 '
[DEBUG] Executing command line: [c:\apps\putty\plink.exe, > myuser@myhost -T -ssh -2 -pw tomcat $SHELL /dev/stdin 'a b c d' < 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' < test.sh]
bash: test.sh: No such file or directory [INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
我怀疑 '
有什么建议吗?
更新:当我说“我尝试将 '” -我是认真的!
【问题讨论】:
-
试过了:
-
也试过了:
-
也试过了:
-
只是为了和你在同一个页面上:你试图在远程机器上执行一个命令,然后将它的结果用作像 Maven 的 args 这样的命令?由此:
<commandlineArgs>"myuser@myhost -T -ssh -2 $SHELL /dev/stdin 'a b c d' < test.sh"</commandlineArgs>Maven 以某种方式得出结论,myhost -T -ssh -2 $SHELL /dev/stdin 'a b c d' < test.sh是主机。 -
问题不在于 plink 也不在于 bash,因为上面的命令行正在运行。问题是我应该如何将它传递给 mvn exec:exec 以使其运行相同:-)