2
問題摘要:我的腳本在鍵入終端時工作正常,但在終端中從.sh文件執行時無法正常工作,爲什麼這是?Linux Ubuntu:腳本在終端中工作,但不是.sh
腳本:
echo World of Clucky - Frisnuk "\033]0;Frisnuk - World of Clucky\a"
#! /usr/bin/env bash
BINDIR="$(dirname "$(readlink -fn "$0")")"
cd "$BINDIR"
while true
do
source /home/clucky/MinecraftServers/Frisnuk/serverconfig/config.sh
#Start Server
java -Xms2000M -Xmx2000M -jar $serverjar.jar nogui
if [ "`date +%w%H`" = "001" ]
then
#Delete map files for The End
rm -R /Frisnuk_the_end
echo "End has been successfully reloaded"
echo "[`date +%D\ %T`] End Reloaded" >> /home/clucky/MinecraftServers/Frisnuk/EndRestart.txt
#Change Item of The Week
weekofyear=`date +%y\-%U`
s=$(<serverconfig/ItemofTheWeek/item$weekofyear.txt)
set -- $s
itemoftheweekid=$2
itemoftheweekprice=$3
xmlstarlet edit -L -u "/scs-shop/itemStack[@type='double']" -v $itemoftheweekid /plugins/ShowCaseStandalone/ffs-storage/ffss_cac8480951254352116d5255e795006252d404d8
xmlstarlet edit -L -u "/scs-shop/price[@type='double']" -v $itemoftheweekprice /plugins/ShowCaseStandalone/ffs-storage/ffss_cac8480951254352116d5255e795006252d404d8
fi
echo "If you want to stop the restart and shut the server off instead, please press Ctrl+C at this time"
for i in 5 4 3 2 1
do
echo "$i..."
sleep 1
done
echo "Restarting Server"
clear
done
而是工作和運行的服務器,它只是這樣說:
World of Clucky - Frisnuk
/home/clucky/MinecraftServers/Frisnuk/craftminecraft.sh: 7: /home/clucky/MinecraftServers/Frisnuk/craftminecraft.sh: source: not found
Error: Unable to access jarfile .jar
If you want to stop the restart and shut the server off instead, please press Ctrl+C at this time
5...
4...
3...
2...
1...
我要洗澡很快,但我會要麼返回今晚晚些時候,或明天早上。感謝您的幫助。
來源可以在終端中找到,但不能在腳本中找到。該文件的位置是正確的,因爲我只是將此腳本複製並粘貼到終端窗口中並且它可以正常工作。 – Clucky
腳本沒有在任何地方定義'$ serverjar'變量。也許你已經在你的環境中定義了它? –
$ serverjar在它正在採購的腳本中定義。 – Clucky