我试图在我的ubuntu服务器/etc/update-motd.d/00-header /etc/update-motd.d/01-sysinfo /etc/update-motd.d/02-footer上修复motd脚本,因为我不断地得到这个奇怪的语法错误,原因很奇怪,上面写着"line 31: syntax error: unexpected end of file“,但是它指向一个没有代码的空空间,这简直是让人费解。
另一个问题是,每当我输入systemctl状态motd时,我就会在屏幕上看到它。
Unit motd.service could not be found.我对被屏蔽的过程有问题,所以我在这个链接systemctl,如何解除掩码中使用了解决方案。
我已经和这个问题斗争了一段时间了,但是我在解决这个问题上正在取得进展,所以我们很感谢你的帮助。
该文件的内容在此文本下面。
#!/bin/sh
#
# 00-header - create the header of the MOTD Copyright (c) 2013 Nick Charlton Copyright (c)
# 2009-2010 Canonical Ltd.
#
# Authors: Nick Charlton
# Dustin Kirkland
#
# This program is free software; you can redistribute it and/or modify it under the terms
# of the GNU General Public License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this
# program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
# Floor, Boston, MA 02110-1301 USA.
[ -r /etc/lsb-release ] && . /etc/lsb-release
if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
# Fall back to using the very slow lsb_release utility
DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi
figlet $(Ourserver) printf "\n"
printf "Welcome to %s (%s).n" "$DISTRIB_DESCRIPTION" "$(uname -r)" printf "\n"发布于 2019-06-10 20:54:58
"line 31: syntax error: unexpected end of file“之所以出现,是因为您有一个奇数的”配对“字符。所谓“配对”字符,我指的是必须以堆叠字符出现的字符,可能是中间的东西。例如,"、'、(、[、{等等。数一下你的引号:
files="/etc/update-motd.d/00-header /etc/update-motd.d/01-sysinfo /etc/update-motd.d/02-footer"
grep --color=always -E "\"|'|\(|\[|\{|\}|\]|\)" $files发布于 2019-06-10 21:39:47
该错误似乎起源于第25行:
25 DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi在fi之前需要有一个分隔符-- ;或换行符(我建议后者保留适当的缩进)。所以
23 if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
24 # Fall back to using the very slow lsb_release utility
25 DISTRIB_DESCRIPTION=$(lsb_release -s -d)
26 fihttps://askubuntu.com/questions/1150098
复制相似问题