gpt4 book ai didi

linux - Bash 脚本第 106 行 : syntax error: unexpected end of file

转载 作者:太空宇宙 更新时间:2023-11-04 05:19:07 25 4
gpt4 key购买 nike

这是我的第一个脚本,所以请保持温柔。我知道意外的文件结尾语法错误通常是 if 没有 fi、for 没有完成或缺少引号等。我找不到上述任何内容。我有一种感觉,这可能是我试图用 echo 写入文件 httpd.conf 的代码部分,但我不确定。有人能发现什么问题、提示、建议吗?谢谢。

enter code here#!/bin/bash


INSTALL_DIRECTORY=/home/jared
export INSTALL_DIRECTORY
cd ; pwd

#If statement to create directories if they are not made
if test -d apache2 && if test -d www2
then
echo "Directories already exist"
else
mkdir apache2 www2
fi

cd apache2

#If statement to create files if they are not made
if test -d bin
then
echo "Directory already exists"
else
mkdir bin
fi

if test -d conf
then
echo "Directory already exists"
else
mkdir conf
fi

if test -d lib
then
echo "Directory already exists"
else
mkdir lib
fi

cd /home/jared/www2

if test -d html
then
echo "Directory already exists"
else
mkdir html
fi

if test -d cgi-bin
then
echo "Directory already exists"
else
mkdir cgi-bin
fi

if test -d ftp
then
echo "Directory already exists"
else
mkdir ftp
fi


#Changing the permissions
chmod -R 755 apache2 ; chmod -R 750 www2
cd www2 ; chmod 722 ftp ; cd ../apache2/bin

#Creating the files
touch httpd ; chmod 755 httpd ; cd /home/jared/www2/html
touch index.html ; chmod 644 index.html ; cd ../cgi-bin
touch process.pl ; chmod 711 process.pl

cd ; cd /home/jared/apache2/conf

#Creating the httpd.conf file if it does not already exist
#and adding details

if test -s httpd.conf
then
echo "File already exists"
else
echo '#
#This is the main Apache HTTP server configuration file.It contains
#configuration directives that give the server its instructions.
#Do not add a slash at the end of the directory path.
#
ServerRoot "/home/jared/apache1"
#
#DocumentRoot: The directory out of which you will server your documents.
#
DocumentRoot "/home/jared/www1"' > /home/jared/apache2/conf/httpd.conf
fi

chmod 644 /home/jared/apache2/conf/httpd.conf

echo $INSTALL_DIRECTORY

最佳答案

if test -d apache2 && if test -d www2

应该是

if test -d apache2 && test -d www2

关于linux - Bash 脚本第 106 行 : syntax error: unexpected end of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44505472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com