使用 bash 创建一个新文件并向其中添加一些文本
Creating a new file and add some text to it using bash
我正在为 LAMP 制作一个基本的安装脚本(准确地说是我的第一个),我遇到了一些困难:
我试图将一些配置放入新文件中,在本例中为 ssl-params
我拙劣的代码:
cat > /etc/apache2/conf-available/ssl-params.conf << ENDOFFILE
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionTickets Off
ENDOFFILE;
以及我的简陋输出:
warning: here-document at line 90 delimited by end-of-file (wanted `ENDOFFILE')
我很好奇我能做些什么不同的事情
使用 heredoc
语法时,您需要使用 heredoc delimiter 打开和关闭 multi-line 文本。报错信息给你提示:
warning: here-document at line 90 delimited by end-of-file (wanted 'ENDOFFILE')
您用 ENDOFFILE
打开了字符串,但用 ENDOFFILE;
关闭了它。
试试这个:
cat > /etc/apache2/conf-available/ssl-params.conf << ENDOFFILE
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionTickets Off
ENDOFFILE
我正在为 LAMP 制作一个基本的安装脚本(准确地说是我的第一个),我遇到了一些困难:
我试图将一些配置放入新文件中,在本例中为 ssl-params
我拙劣的代码:
cat > /etc/apache2/conf-available/ssl-params.conf << ENDOFFILE
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionTickets Off
ENDOFFILE;
以及我的简陋输出:
warning: here-document at line 90 delimited by end-of-file (wanted `ENDOFFILE')
我很好奇我能做些什么不同的事情
使用 heredoc
语法时,您需要使用 heredoc delimiter 打开和关闭 multi-line 文本。报错信息给你提示:
warning: here-document at line 90 delimited by end-of-file (wanted 'ENDOFFILE')
您用 ENDOFFILE
打开了字符串,但用 ENDOFFILE;
关闭了它。
试试这个:
cat > /etc/apache2/conf-available/ssl-params.conf << ENDOFFILE
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
SSLCompression off
SSLUseStapling on
SSLStaplingCache "shmcb:logs/stapling-cache(150000)"
SSLSessionTickets Off
ENDOFFILE