所以我想做一个bash脚本,但每当我运行它时,我都会遇到“错误的替换”错误。我已经浏览了stackoverflow并尝试了一些解决方案但没有工作:/ 有什么想法吗?
#!/bin/bash
printf "Hello. This is an OTS setup script provided by Damon at Otland. Please standby as user input may be required."
read -r -p "Do you want to install the webpanel? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
wget https://raw.githubusercontent.com/NicolasLoew/vps/master/panelsetup.sh
sh panelsetup.sh
fi
printf "If you installed webpanel please navigate to http://yourip:2004/ and follow install instructions."
printf "Once you have installed the webpanel login and go to Enduser-->Configuration-->Apache and delete everything in the config and replace it with https://raw.githubusercontent.com/NicolasLoew/vps/master/apacheconfig. This will be needed for Znote later."
read -r -p "Do you want to compile latest TFS? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
wget https://raw.githubusercontent.com/NicolasLoew/vps/master/tfsauto.sh
sh tfsauto.sh
fi
printf "You have successfully compiled TFS! You can start it by going to cd forgottenserver and execute ./tfs. Dont forget to configure config.lua though. You can create database in webpanel-->enduser."
read -r -p "Do you want to install ZnoteAAC? [Y/n]" response
response=${response,,} # tolower
if [[ $response =~ ^(yes|y| ) ]]; then
wget https://raw.githubusercontent.com/NicolasLoew/vps/master/znotesetup.sh
sh znotesetup.sh
fi
printf "You havee successfully setup ZnoteAAC. Navigate to http://yourip and follow the instructions."
根据评论进行修改
编辑被调用为
sh otsetup.sh
答案 0 :(得分:1)
您使用sh
而不是bash
调用脚本。
用于将字符串置于小写
的参数替换response=${response,,} # to lower
仅适用于4.0版本的bash
因此,要么使用现代bash调用脚本,要么使用不依赖于bash的语法。
例如
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')