Re: system command in dblink?

From: "mike stanton" <mike(dot)stanton(at)autocastillo(dot)cl>
To: "AI Rumman" <rummandba(at)gmail(dot)com>, "pgsql-general General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: system command in dblink?
Date: 2011-06-14 20:57:13
Message-ID: 013601cc2ad5$a41daa70$cb6ea8c0@mike
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

you could try creating a perl function

CREATE OR REPLACE FUNCTION "public"."system" (cmd varchar) RETURNS text AS
$body$
return `$_[0]`;
$body$
LANGUAGE 'plperlu' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

then using it in this way

sql = 'select system( '
|| ' ''/home/iv_fmaster/bin/main_wms 99 '
|| new.iddocsalida || ''' )';

select dblink_exec('paso_lx',sql,TRUE)
into ifres;

cheers mike stanton

----- Original Message -----
From: AI Rumman
To: pgsql-general General
Sent: Tuesday, June 14, 2011 2:17 AM
Subject: [GENERAL] system command in dblink?

Is it possible to execute system commands in dblink connections?

I need to execute \i /tmp/test.sh in a remote connection from my psql client prompt.
I connected with the remote db using dblink_connect.

select dblink_connect('conn_1', 'dbname=newdb');

Any help please.

__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 6208 (20110614) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-06-14 22:30:10 Re: trouble building user defined agg function with plpython
Previous Message Rick Harding 2011-06-14 18:51:56 trouble building user defined agg function with plpython