title: Bash script : Login to postgres home from shell script
body: <p>I have to take a data dump from my postgres database.</p>
  
  <p>How do I log in to the postgres home ? . I have the following script but it doesn't work :    </p>
  
  <pre><code>#!/bin/sh$                                                                      
  export PASSWORD= something                                                      
  echo $PASSWORD | sudo -S su postgres                                                                                                                 
  pg_dump somedb &gt; dump.txt+`date +%Y-%m-%d`          
  </code></pre>
  
  <p>However when I run this script I do not get logged to <code>postgres@gauss:$</code> at the same time script doesn't throw an error. Is there something I am doing wrong here ? </p>