On Thu, 6 Mar 2003, Carl Olivier wrote:
> OK, so I am going to ask a bad question, but hey, here goes:
>
> In MSSql it is possible to run Shell commands from within Sql via any
> interface (suchg as JDBC) using mechanism MSSql provides....
>
> Is this possiible in POSTGRESql? I know it is a security hole (through
> which many MS Servers are exploited), but was just wondering!
>
> Anyway, thanks in advance,
Could be easiest with plperlu (you need perl and plperl compiled
& installed, though):
# createlang plperlu
and after that
create or replace function do_readpipe(text) returns text as '
my $command = shift;
return `$command`;
'
language 'plperlu';
create or replace function do_shell(text) returns int as '
my $command = shift;
return system $command;
'
language 'plperlu';
select do_readpipe('cat /etc/passwd|grep root| cut -f 1-5 -d :');
do_readpipe
-----------------
root:x:0:0:root
(1 row)
ilmo=# select do_shell('echo "Hello World"|mailx antti.haapala@iki.fi');
do_shell
----------
0
(1 row)
Latter worked as expected.
--
Antti Haapala
+358 50 369 3535
ICQ: #177673735