Я пытаюсь исправить скрипт motd на моем сервере Ubuntu с именем /etc/update-motd.d/00-header
/etc/update-motd.d/01-sysinfo
/etc/update-motd.d/02-footer
, потому что я продолжаю получать эту странную синтаксическую ошибку по какой-то странной причине, которая говорит «line 31: syntax error: unexpected end of file
», но она указывает на пустое пространство без кода, который просто сбивает с толку.
Другая проблема заключается в том, что всякий раз, когда я набираю systemctl status 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 <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.com>
#
# 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"
«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
Ошибка появляется в строке 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 fi