“:错误的变量名读取:网站”

伊恩·奥伯多夫(Ian Oberdorf)

因此,我试图为我的Ubuntu LAMP服务器制作一个.sh脚本,以使其更容易将新网站添加到apache2中,但是当我尝试执行时,出现错误

: bad variable name read: website

我已经进行了一些搜索,但找不到所需的答案,并且在脚本中有很多地方出现了与导致错误的行匹配相同设置的行。这是我认为引起错误的生产线上的设置

read -p 'What is the website title (no spaces): ' website

这是整个脚本:

echo Starting website builder
read -p 'What is the website title (no spaces): ' website
echo Website title saved as $website
echo creating storage folder
mkdir -p /var/www/$website
echo changing file permissions
chown -R $name:$name /var/www/$website
chmod -R 755 /var/www/$website
echo creating test file
echo <html> >> /var/www/$website/index.html
echo <head> >> /var/www/$website/index.html
echo    <title>Success</title> >> /var/www/$website/index.html
echo </head> >> /var/www/$website/index.html
echo <body> >> /var/www/$website/index.html
echo    <h1>$website is operational</h1> >> var/www/$website/index.html
echo </body> >> /var/www/$website/index.html
echo </html> >> /var/www/$website/index.html
clear
cat /var/www/$website/index.html
echo
read -p "press [Enter] to continue"
clear
echo creating $website.conf file
echo <VirtualHost *:80> >> /etc/apache2/sites-available/$website.conf
read -p 'Enter ServerName: ' ServerName
echo        ServerName $ServerName >> /etc/apache2/sites-available/$website.conf
read -p 'Enter ServerAlias (domain name): ' ServerAlias
echo        ServerAlias $ServerAlias >> /etc/apache2/sites-available/$website.conf
read -p 'Enter ServerAdmin: ' ServerAdmin
echo        ServerAdmin $ServerAdmin >> /etc/apache2/sites-available/$website.conf
echo        DocumentRoot var/www/$website >> /etc/apache2/sites-available/$website.conf
echo        ErrorLog ${APACHE_LOG_DIR}/error.log >> /etc/apache2/sites-available/$website.conf
echo        CustomLog ${APACHE_LOG_DIR}/access.log combined >> /etc/apache2/sites-available/$website.conf
echo </VirtualHost>
clear
cat /etc/apache2/sites-available/$website.conf
echo 
read -p "press [Enter] to continue"
clear
echo activating website
a2ensite $website
service apache2 restart
echo Open a web browser on any pc and visit $ServerAlias. If you have errors make sure the alias and external ip was properly set up on the domainservice you signed up with.
read -p 'Process completed. Press [Enter] to end.'
clear
点心

混乱的错误消息指出Windows行尾存在问题。您可以使用以下命令将文件中的行尾转换为换行符(Unix格式):

sed -i 's/\r$//' /path/to/your/script

或(您可能需要先安装dos2unix 安装dos2unix):

dos2unix /path/to/your/script

进一步阅读:

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

由cron启动的bash脚本中的“变量名错误”

来自分类Dev

使用typedef作为变量名不会产生任何错误

来自分类Dev

CMD变量名限制?

来自分类Dev

R缺少变量名

来自分类Dev

如何获取变量名

来自分类Dev

使变量名不能包含+?

来自分类Dev

在Haxe中,如何读取宏内的变量名?

来自分类Dev

动态创建变量名?

来自分类Dev

使用“读取变量”的“变量名错误”

来自分类Dev

获取NullReferenceException的变量名

来自分类Dev

用其他变量名替换变量名

来自分类Dev

javascript,$。ajax,变量名

来自分类Dev

如何获取Shell函数以读取变量中的值而不是VBA中的变量名?

来自分类Dev

名称(变量名)未定义错误

来自分类Dev

Nokogiri返回变量名而不是网站上的实际数据?

来自分类Dev

freebsd:非法变量名

来自分类Dev

代码因错误而中断:$$ slots是非法的变量名

来自分类Dev

找不到变量名

来自分类Dev

匹配变量名

来自分类Dev

获取数组的变量名

来自分类Dev

使用typedef作为变量名不会产生任何错误

来自分类Dev

读取具有变量名的xml值

来自分类Dev

在Haxe中,如何在宏中读取变量名?

来自分类Dev

Haskell读取变量名

来自分类Dev

ffmpeg不接受从文件读取的变量名

来自分类Dev

Bash-在变量名中扩展变量名

来自分类Dev

sh-只读数组:错误的变量名

来自分类Dev

动态变量名/增量变量名

来自分类Dev

Python变量名