update pgdb.sh to allow file output