Home > other >  Creating a new file and add some text to it using bash
Creating a new file and add some text to it using bash

Time:05-21

I'm making a basic installation script (my first to be precise) for LAMP, and I experienced some difficulties:

I trying to put some configuration in a new file, in this case for ssl-params

My humble code:

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;

And my humble output:

warning: here-document at line 90 delimited by end-of-file (wanted `ENDOFFILE')

I'm curious what I can do differently

CodePudding user response:

When using the heredoc syntax, you need to both open and close the multi-line text with the heredoc delimiter. The error message gives you the hint:

warning: here-document at line 90 delimited by end-of-file (wanted 'ENDOFFILE')

You opened your string with ENDOFFILE but closed it with ENDOFFILE;.

Try this instead:

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
  • Related