Re: Accessing environment variables from psql (SOLVED)

Поиск
Список
Период
Сортировка
От Leif B. Kristensen
Тема Re: Accessing environment variables from psql (SOLVED)
Дата
Msg-id 200504091553.12528.leif@solumslekt.org
обсуждение исходный текст
Ответ на Accessing environment variables from psql  ("Leif B. Kristensen" <leif@solumslekt.org>)
Ответы Re: Accessing environment variables from psql (SOLVED)  (Andreas Seltenreich <seltenreich@gmx.de>)
Список pgsql-general
On Saturday 09 April 2005 13:59, Leif B. Kristensen wrote:
> Is there a way to access environment variables from psql?

After scrutinizing the psql documentation at
<http://www.postgresql.org/docs/8.0/static/app-psql.html>, I found that
this actually works:

leif=> \set importdir `echo $IMPORTDIR`
leif=> \echo :importdir
/home/leif/slekta/import/scripts

This doesn't:

leif=> \i :importdir/test.sql
\i: extra argument "/test.sql" ignored

But this does:

leif=> \cd :importdir
leif=> \i test.sql

So, the problem is solved, sort of. It may also be prudent to save the
old pwd and return there when the work is done:

leif=> \set olddir `echo $PWD`
leif=> \set importdir `echo $IMPORTDIR`
leif=> \cd :importdir
leif=> \i test.sql
leif=> \cd :olddir
--
Leif Biberg Kristensen
http://solumslekt.org/

В списке pgsql-general по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: create user with database and contrib
Следующее
От: John DeSoi
Дата:
Сообщение: table and column information from cursor?