dbTalk Databases Forums  

PostgreSQL with Shell Scripts

comp.databases.postgresql comp.databases.postgresql


Discuss PostgreSQL with Shell Scripts in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fuzzydave
 
Posts: n/a

Default PostgreSQL with Shell Scripts - 12-15-2006 , 08:38 AM






I am writing a backup application currently and I am working on the
shell scripts that will
handle the pg_dumpall and pg_restore functions. One of the things I
want the script to
do is to query the database and read the DB name and the true or false
flag to know what
to display. I select these names and put them into a variable which all
works find, the
problem comes with the way PSQL in postgres formats the response to the
query.

Instead of receiving

db_one
db_two

etc, I receive

db_name
--------------
db_one
db_two

So when I call back the data I get psql's formatting characters too is
there a way to
turn formatting off in psql so I just get the actual data called back
from the query to
stuff into my shell script array/variables without psql's command line
formatting?


Cheers
David Phillips


Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: PostgreSQL with Shell Scripts - 12-15-2006 , 09:10 AM






Fuzzydave <dav.phillips (AT) ntlworld (DOT) com> wrote:
Quote:
Instead of receiving

db_one
db_two

etc, I receive

db_name
--------------
db_one
db_two

So when I call back the data I get psql's formatting characters too is
there a way to
turn formatting off in psql so I just get the actual data called back
from the query to
stuff into my shell script array/variables without psql's command line
formatting?
Use the -t flag of psql.

It's all in the man page.

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.