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@aklaver.com