Thread: 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.
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.
On Tue, Jun 14, 2011 at 1:17 AM, AI Rumman <rummandba@gmail.com> wrote: > 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'); the '\i' syntax only means anything to psql, so no. This might help though: http://plsh.projects.postgresql.org/ merlin
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;
$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;
|| ' ''/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 RummanSent: Tuesday, June 14, 2011 2:17 AMSubject: [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