【发布时间】:2016-04-21 06:02:51
【问题描述】:
我正在尝试使用带有以下模板的 appassembler-maven-plugin 生成 shutdown.sh 文件
#!/bin/sh
@LICENSE_HEADER@
@ENV_SETUP@
kill -1 $(cat ./samp.pid)
生成的sh文件如下。
#!/bin/sh
# ====================================================================
# Organization : Sample Software JLT
# Copyright (c) 2012
# ====================================================================
kill -1 $(cat ./aqua.pid)
但是,当我尝试在 linux vi 编辑器中打开它时,我在行的每一端都得到 ^M 字符。如何避免它。
我正在使用下面的插件来生成 sh 文件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>Aqua-Shutdown</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<configurationDirectory>aqua/config</configurationDirectory> <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<showConsoleWindow>false</showConsoleWindow>
<platforms>
<platform>windows</platform>
<platform>unix</platform>
</platforms>
<binFileExtensions>
<unix>.sh</unix>
</binFileExtensions>
<unixScriptTemplate>${basedir}/template/unixShutdownScriptTemplate</unixScriptTemplate> <windowsScriptTemplate>${basedir}/template/windowScriptTemplate</windowsScriptTemplate>
<repositoryLayout>flat</repositoryLayout>
<useAsterikClassPath>true</useAsterikClassPath>
<repositoryLayout>flat</repositoryLayout>
<assembleDirectory>target/assembleDir</assembleDirectory>
<repositoryName>samp/dependencies</repositoryName>
<programs>
<program>
<mainClass>com.samp.aqua.bootstrap.BootstrapAgent</mainClass>
<name>shutdown</name>
<commandLineArguments>
<commandLineArgument>SHUTDOWN</commandLineArgument>
</commandLineArguments>
</program>
</programs>
</configuration>
</execution>
</executions>
</plugin>
【问题讨论】:
-
^M CR 0x0d 13 CARRIAGE RETURN (CR)- Microsoft 的新行是\r\n或CARRIAGE RETURNNEW LINE而Unix 只使用\n。 -
如果你在 DOS 系统下编写文件,你很可能会有这样的 ^M。您可以通过运行
dos2unix来“清理”文件。 -
你想实现什么样的关机脚本。您使用的是 deamon 还是 appassembler-maven-plugin 中的什么?还是使用 JSW?
-
谢谢你的重播。我正在使用appassembler-maven-plugin和上面的配置。
-
这不是我想要的。我知道您正在使用 appassembly-maven-plugin ....此外,您为什么使用如此古老的版本?见here for the uptodate information。也许 JSW 是您已经拥有这些东西的更好的选择...