title: Shell script won't recognize heredoc delimiter
body: <p>I am trying to write a very simple shell script in Linux. The Scenario I am trying to achieve is: </p>
  
  <p>Creating an user account and giving it a password internally (No interaction with user allowed for this). Once successful, Just display a success message to the user. None of the rest should be diplayed.</p>
  
  <p>On RHEL this turned out to be pretty simple as passwd command accepts the --stdin option which helped me pass the input via Pipe. And I redirected the standard output in a log file. [Not sharing that code as it's tad simple and explained multiple times here for different question on StackExcahnge.]</p>
  
  <p>However, Ubuntu is not accepting the --stdin option for passwd hence I had to use the below method:</p>
  
  <pre><code>#!/bin/bash
  useradd -m demo &amp;&gt;path/to/logfile.log
  passwd demo &amp;&gt;&gt;path/to/logfile.log &lt;&lt; EOF
  myPasswd
  myPasswd
  EOF
  echo "User demo successfully added to the system."
  </code></pre>
  
  <p>Now The problem here is my output does not print the echo statement and also displays a warning:</p>
  
  <pre><code>root@ubuntu:~# ./usercreate.sh 
  ./usercreate.sh: line 8: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
  root@ubuntu:~# 
  </code></pre>
  
  <p>instead of my expected one:</p>
  
  <pre><code>root@ubuntu:~# ./usercreate.sh 
  User demo successfully added to the system.
  root@ubuntu:~# 
  </code></pre>
  
  <p>Please help me with these two things:</p>
  
  <ol>
  <li>Is there a way to suppress that warning for this script only? </li>
  <li>Why is it not printing my echo statement and how can I print it?</li>
  </ol>
  
  <p>PS: Another way or idea to write this script is also welcome </p>
  
  <p>Thanks</p>