首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我得到了一个motd头语法错误,我需要帮助启用motd

我得到了一个motd头语法错误,我需要帮助启用motd
EN

Ask Ubuntu用户
提问于 2019-06-10 20:09:15
回答 2查看 313关注 0票数 0

我试图在我的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时,我就会在屏幕上看到它。

代码语言:javascript
复制
Unit motd.service could not be found.

我对被屏蔽的过程有问题,所以我在这个链接systemctl,如何解除掩码中使用了解决方案。

我已经和这个问题斗争了一段时间了,但是我在解决这个问题上正在取得进展,所以我们很感谢你的帮助。

该文件的内容在此文本下面。

代码语言:javascript
复制
#!/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"
EN

回答 2

Ask Ubuntu用户

发布于 2019-06-10 20:54:58

"line 31: syntax error: unexpected end of file“之所以出现,是因为您有一个奇数的”配对“字符。所谓“配对”字符,我指的是必须以堆叠字符出现的字符,可能是中间的东西。例如,"'([{等等。数一下你的引号:

代码语言:javascript
复制
files="/etc/update-motd.d/00-header /etc/update-motd.d/01-sysinfo /etc/update-motd.d/02-footer"
grep --color=always -E "\"|'|\(|\[|\{|\}|\]|\)" $files
票数 0
EN

Ask Ubuntu用户

发布于 2019-06-10 21:39:47

该错误似乎起源于第25行:

代码语言:javascript
复制
25          DISTRIB_DESCRIPTION=$(lsb_release -s -d) fi

fi之前需要有一个分隔符-- ;或换行符(我建议后者保留适当的缩进)。所以

代码语言:javascript
复制
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  fi
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1150098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档