title: Run a psql query from a shell script
body: <p>I have a PSQL statement which needs to be run from a shell script.
  I have tried below but no success</p>
  
  <p><code>ctfdb</code> is my database</p>
  
  <pre><code>psql ctfdb &lt;&lt;EOF
  statement
  EOF
  </code></pre>
  
  <blockquote>
    <p>psql: FATAL:  Peer authentication failed for user "root"</p>
  </blockquote>
  
  <p>I have even tried giving "sudo psql"</p>
  
  <blockquote>
    <p>Sorry, user root is not allowed to execute '/bin/psql ctfdb' as root
    on my server</p>
  </blockquote>
  
  <p>Any suggestions?</p>