Shell access & send email from PLPGSQL?

Started by Philippe Langover 22 years ago7 messagesgeneral
Jump to latest
#1Philippe Lang
philippe.lang@attiksystem.ch

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some unix commands to the server, through the database...

Thanks

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

#2John Sidney-Woollett
johnsw@wardbrook.com
In reply to: Philippe Lang (#1)
Re: Shell access & send email from PLPGSQL?

Why not create a cron script which connects to the database and queries
your tables (using psql). Have it generate an output (shell) script which
your original script then calls.

Unfortunately I know how to do this with Oracle, but not postgres *yet*,
but I suspect that in principle this idea will work.

Maybe someone else has an example, or a better suggestion.

John Sidney-Woollett

Philippe Lang said:

Show quoted text

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some
unix commands to the server, through the database...

Thanks

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: Philippe Lang (#1)
Re: Shell access & send email from PLPGSQL?

Hello

If you require only send mail, try pgsendmail.
http://sourceforge.net/project/showfiles.php?group_id=35804.
You can use plsh too.
http://developer.postgresql.org/~petere/pgplsh/

regards
Pavel Stehule

On Tue, 9 Dec 2003, Philippe Lang wrote:

Show quoted text

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some unix commands to the server, through the database...

Thanks

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

#4Shridhar Daithankar
shridhar_daithankar@myrealbox.com
In reply to: Philippe Lang (#1)
Re: Shell access & send email from PLPGSQL?

Philippe Lang wrote:

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some unix commands to the server, through the database...

http://archives.postgresql.org/pgsql-novice/2002-01/msg00098.php

HTH

Shridhar

#5Philippe Lang
philippe.lang@attiksystem.ch
In reply to: Shridhar Daithankar (#4)
Re: Shell access & send email from PLPGSQL?

Hello,

This is exactly what I needed. It works just fine for me, except when a function is being created through the pgAdmin III (version 1.02 under Windows). In this case, I think functions are being stored in the database with a CR/LF at the end, what the plpgsh engine does not like at all!

Except this, that's fine. Thanks.

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

-----Message d'origine-----
De : Pavel Stehule [mailto:stehule@kix.fsv.cvut.cz]
Envoyé : mardi, 9. décembre 2003 11:33
À : Philippe Lang
Cc : pgsql-general@postgresql.org
Objet : Re: [GENERAL] Shell access & send email from PLPGSQL?

Hello

If you require only send mail, try pgsendmail.
http://sourceforge.net/project/showfiles.php?group_id=35804.
You can use plsh too.
http://developer.postgresql.org/~petere/pgplsh/

regards
Pavel Stehule

On Tue, 9 Dec 2003, Philippe Lang wrote:

Show quoted text

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some unix commands to the server, through the database...

Thanks

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

#6Joshua D. Drake
jd@commandprompt.com
In reply to: Philippe Lang (#5)
Re: Shell access & send email from PLPGSQL?

Philippe Lang wrote:

Hello,

This is exactly what I needed. It works just fine for me, except when a function is being created through the pgAdmin III (version 1.02 under Windows). In this case, I think functions are being stored in the database with a CR/LF at the end, what the plpgsh engine does not like at all!

You can also use plPHP with it's built in mail() function.

Except this, that's fine. Thanks.

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

-----Message d'origine-----
De : Pavel Stehule [mailto:stehule@kix.fsv.cvut.cz]
Envoy� : mardi, 9. d�cembre 2003 11:33
� : Philippe Lang
Cc : pgsql-general@postgresql.org
Objet : Re: [GENERAL] Shell access & send email from PLPGSQL?

Hello

If you require only send mail, try pgsendmail.
http://sourceforge.net/project/showfiles.php?group_id=35804.
You can use plsh too.
http://developer.postgresql.org/~petere/pgplsh/

regards
Pavel Stehule

On Tue, 9 Dec 2003, Philippe Lang wrote:

Hello,

How can open a unix shell from a PLPGSQL function / trigger?

I would like to send an email from a postgres database, and also send some unix commands to the server, through the database...

Thanks

-------------------------
Philippe Lang
Attik System
http://www.attiksystem.ch

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

-- 
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-222-2783 - jd@commandprompt.com - http://www.commandprompt.com
Editor-N-Chief - PostgreSQl.Org - http://www.postgresql.org 
In reply to: Joshua D. Drake (#6)
Re: Shell access & send email from PLPGSQL?

Dear Philippe Lang,

For e-mail from PgSQL function you need is

http://pgmail.sourceforge.net/

Tell me if it help's n one of my project its a great help

Regards,
V Kashyap