我正在尝试从 shell 脚本调用 java jar。它适用于窗口批处理脚本。我试图将这个工作批处理脚本翻译成一个 shell 脚本,但没有让它工作。错误在哪里?
原始批处理文件(完美运行):
@echo off
rem set the right host here
set host=example.com
set port=8080
set urlPartBeforeApiVersion=/project/api
rem geographical region
set west=47.358352
set south=8.493598
set east=47.406704
set north=8.560889
set numberOfVehicles=10
set idPerfix=SIM_KSDN128D
set vehicleSpeed=40
set gpsSendInterval=10
set cloudmadeApiKey=kldhfjsghjf83hf83hf83hf89whs89
java -jar %~p0dist/application.jar %host% %port% %west% %south% %east% %north% %numberOfVehicles% %idPerfix% %vehicleSpeed% %gpsSendInterval% %urlPartBeforeApiVersion% %cloudmadeApiKey%
pause
shell脚本(不起作用):
#!/bin/sh
host="example.com"
port="8080"
urlPartBeforeApiVersion="/project/api"
west="47.358352"
south="8.493598"
east="47.406704"
north="8.560889"
numberOfVehicles="10"
idPerfix="SIM_KSDN128D"
vehicleSpeed="40"
gpsSendInterval="10"
cloudmadeApiKey="kldhfjsghjf83hf83hf83hf89whs89"
java -jar $(dirname $0)/dist/application.jar $host $port $west $south $east $north $numberOfVehicles $idPerfix $vehicleSpeed $gpsSendInterval $urlPartBeforeApiVersion $cloudmadeApiKey
应用程序抛出 Java NumberFormatException 并退出。我在 Windows 7 和 centos 上的 cygwin 上测试了脚本。