Retrieve filename within a script

Started by Patrick Ficheover 1 year ago3 messagesgeneral
Jump to latest
#1Patrick Fiche
patrick.fiche@aqsacom.com

Hi,

I was wondering if it was possible to get the filename provided as an argument to psql.
psql -f /tmp/test.sql

I would like a command in test.sql that would be able to retrieve the full pathname (/tmp/test.sql).

Regards,

Patrick

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Patrick Fiche (#1)
Re: Retrieve filename within a script

On 11/14/24 00:42, Patrick FICHE wrote:

Hi,

I was wondering if it was possible to get the filename provided as an
argument to psql.

Not that I know of.

psql -f /tmp/test.sql

I would like a command in test.sql that would be able to retrieve the
full pathname (/tmp/test.sql).

Regards,

Patrick

--
Adrian Klaver
adrian.klaver@aklaver.com

#3Vincent Veyron
vv.lists@wanadoo.fr
In reply to: Patrick Fiche (#1)
Re: Retrieve filename within a script

On Thu, 14 Nov 2024 08:42:36 +0000
Patrick FICHE <Patrick.Fiche@aqsacom.com> wrote:

I was wondering if it was possible to get the filename provided as an argument to psql.
psql -f /tmp/test.sql

Since you know it already, you could pass it as a variable :

psql -f /tmp/test.sql -v my_path='/tmp/test.sql'

and retrieve it with SELECT :'my_path';

--
Bien à vous, Vincent Veyron

https://marica.fr
Logiciel de gestion des contentieux juridiques, des contrats et des sinistres d'assurance