Search Postgresql Archives

Re: Run external command as part of an sql statement ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/07/2018 02:35 PM, David Gauthier wrote:
Hi:

At the psql prompt, I can do something like...
    "select  \! id -nu"
...to get the uid of whoever's running psql.
I want to be able to run a shell command like this from within a stored procedure.  Is there a way to do this ?

PL/sh?:

https://github.com/petere/plsh

CREATE OR REPLACE FUNCTION id() RETURNS text AS '
#!/bin/sh
id -nu
' LANGUAGE plsh;

aklaver@tito:~> psql -d test -U postgres

test=# select * from id();
    id
----------
 postgres


It is an untrusted language so you will need to run as a superuser.



Thanks


--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux