通过获取当前目录,设置shell脚本的当前工作目录,实现文件相对位置的调整,解决全路径访问应用程序。
windows 环境下
cd /d %~dp0
SETLOCAL EnableDelayedExpansion
TITLE SmartTileServer-Startup
set "CURRENT_DIR=%cd%"
cd "%CURRENT_DIR%"
SET server=SmartTileServer-win.exe
if exist "%CURRENT_DIR%\%server%" goto doneSetArgs
echo Cannot find "%CURRENT_DIR%\%server%"
goto end
:doneSetArgs
@start %server% 6
@exit
:end
linux环境下
CURPATH=$(cd "$(dirname "$0")"; pwd)
#echo $CURPATH
cd $CURPATH
server="SmartTileServer"
myexe=$CURPATH/$server
echo $myexe
nohup $myexe 6 &
exit