Note that there are some explanatory texts on larger screens.

plurals
  1. POUnexpected End of File in a Bash script?
    primarykey
    data
    text
    <p>This is just a little script to add a user to an e-mail MySQL database, assign an alias to him if an argument is defined, send a welcome email to the user and send e-mails to everybody else notifying about the newcomer. But everytime I try to run the script, I only get the message <code>UNEXPECTED END OF FILE</code>. Here's the script:</p> <pre><code>#! /bin/bash USER=$1 SECTOR=$2 if [ -z "${SECTOR}" ]; then mysql --host=localhost --user=verysecretdatabaseuser --password=verysecretdatabasepass mydatabase &lt;&lt; EOF insert into users (email,name,uid,gid,homedir,maildir,crypt,force_change_pwd) values("${USER}@example.com.br","${USER}",1001,1001, "/var/mail/${USER}/","/var/mail/${USER}/.maildir/",ENCRYPT("verysecretdefaultpass"), "yes" ); EOF else mysql --host=localhost --user=verysecretdatabaseuser --password=verysecretdatabasepass mydatabase &lt;&lt; EOF insert into users(email,name,uid,gid,homedir,maildir,crypt,force_change_pwd) values("${USER}@example.com.br","${USER}",1001,1001,"/var/mail/${USER}/","/var/mail/${USER}/.maildir/",ENCRYPT("verysecretdefaultpass"), "yes" ); EOF insert into alias(alias,destination) values ("${SECTOR}@example.com.br", "${USER}@example.com.br"); EOF fi # send e-mail so my postfix can create the mail directories /usr/sbin/sendmail -f me@example.com.br "${USER}@example.com.br" &lt;&lt; EOF Subject: Bem Vindo! Seja bem vindo ao Servidor de e-mails da Empresa! Com muito orgulho hospedamos nosso e-mail em nosso próprio servidor. Em caso de dúvidas contacte &lt;me@example.com.br&gt; . EOF # fetching everyone already in the database users=`mysql --user=myverysecretuser --password=myverysecretpass -s -N -e "SELECT myverysecretfield FROM myverysecretdatabase.myverysecretusertable"` #sending an e-mail to each user for user in $users do echo "${user}" /usr/sbin/sendmail -f me@example.com.br "${user}" &lt;&lt; EOF Subject: Funcionario novo! Prezados, deem as boas vindas ao funcionario novo "${USER}" que acabou de entrar no departamento de "${SECTOR}". Para se comunicar com o funcionario novo, basta enviar e-mails para: "${USER}@example.com.br". O funcionario novo tambem recebera e-mails que forem enviados para "${SECTOR}@example.com.br". . EOF done </code></pre> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload