Re: psql variables - Mailing list pgsql-general

From ptjm@interlog.com (Patrick TJ McPhee)
Subject Re: psql variables
Date
Msg-id 3aj3prF6ba6tgU1@uni-berlin.de
Whole thread Raw
In response to psql variables  (Paul Cunningham <paul@blueseacommunications.com>)
Responses Re: psql variables
List pgsql-general
In article <4235B688.8000407@blueseacommunications.com>,
Paul Cunningham <paul@blueseacommunications.com> wrote:
% I use a bash script (similar to following example) to update tables.
%
% psql -v passed_in_var=\'some_value\'  -f script_name ....
%
% Is it possible to pass a value back from psql to the bash script?

If you run it like this

 $(psql -v passed_in_var=\'some_value\'  -f script_name)

and arrange for all the script output to be in the form

  var1="value 1" var2="value 2"
  var3="value 3" ...

then var1, var2, etc will be set in bash (or ksh, or the posix shell).
Note that there are no spaces around the equals signs.
--

Patrick TJ McPhee
North York  Canada
ptjm@interlog.com

pgsql-general by date:

Previous
From: "Andrus Moor"
Date:
Subject: Re: Referential integrity using constant in foreign key
Next
From: "sales@qlrmanager.com"
Date:
Subject: Looking for persons interested in a Beta version of a PostgreSQL reporting tool