Re: calling a shell script from pl/pgsql

Lists: pgsql-sql
From: "Jeff Barrett" <jbarrett(at)familynetwork(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: calling a shell script from pl/pgsql
Date: 2001-09-10 16:14:13
Message-ID: 9nip2p$1s5o$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

How can I call a shell script from within a pl/pgsql function that is called
as from a trigger. I do not want to interact with the script I just want it
to run. I do want the trigger to wait for the script it called to complete
before returning a value.

Any ideas would be greatly appreciated.

Thanks,

Jeff Barrett


From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jeff Barrett <jbarrett(at)familynetwork(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-10 17:22:35
Message-ID: Pine.BSF.4.21.0109101018210.15401-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On Mon, 10 Sep 2001, Jeff Barrett wrote:

> How can I call a shell script from within a pl/pgsql function that is called
> as from a trigger. I do not want to interact with the script I just want it
> to run. I do want the trigger to wait for the script it called to complete
> before returning a value.
>
> Any ideas would be greatly appreciated.

I don't think you can do that from within pl/pgsql. You'd probably need a
function in pl/tclu or c.


From: Larry Rosenman <ler(at)lerctr(dot)org>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Jeff Barrett <jbarrett(at)familynetwork(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-10 17:51:55
Message-ID: 20010910125155.A21086@lerami.lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

* Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> [010910 12:37]:
> On Mon, 10 Sep 2001, Jeff Barrett wrote:
>
> > How can I call a shell script from within a pl/pgsql function that is called
> > as from a trigger. I do not want to interact with the script I just want it
> > to run. I do want the trigger to wait for the script it called to complete
> > before returning a value.
> >
> > Any ideas would be greatly appreciated.
>
> I don't think you can do that from within pl/pgsql. You'd probably need a
> function in pl/tclu or c.
You can also look at Peter Eisentraut's PL/sh, but there are
portability issues with it:

I can't seem to find the correct page at the moment, but it's out
there.

LER

>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Jeff Barrett <jbarrett(at)familynetwork(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: pl/sh (was Re: calling a shell script from pl/pgsql)
Date: 2001-09-10 18:17:19
Message-ID: Pine.BSO.4.10.10109101415580.17071-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On Mon, 10 Sep 2001, Stephan Szabo wrote:

> On Mon, 10 Sep 2001, Jeff Barrett wrote:
>
> > How can I call a shell script from within a pl/pgsql function that is called
> > as from a trigger. I do not want to interact with the script I just want it
> > to run. I do want the trigger to wait for the script it called to complete
> > before returning a value.
> >
> > Any ideas would be greatly appreciated.
>
> I don't think you can do that from within pl/pgsql. You'd probably need a
> function in pl/tclu or c.
Or pl/perlu! (Sorry, had to say it).

Actually, I remember that Jan once mentioned something about pl/SH. I
don't know what's the status of it?


From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Alex Pilosov <alex(at)pilosoft(dot)com>
Cc: Jeff Barrett <jbarrett(at)familynetwork(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: pl/sh (was Re: calling a shell script from pl/pgsql)
Date: 2001-09-10 18:19:13
Message-ID: Pine.BSF.4.21.0109101117440.15751-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql


On Mon, 10 Sep 2001, Alex Pilosov wrote:

> On Mon, 10 Sep 2001, Stephan Szabo wrote:
>
> > On Mon, 10 Sep 2001, Jeff Barrett wrote:
> >
> > > How can I call a shell script from within a pl/pgsql function that is called
> > > as from a trigger. I do not want to interact with the script I just want it
> > > to run. I do want the trigger to wait for the script it called to complete
> > > before returning a value.
> > >
> > > Any ideas would be greatly appreciated.
> >
> > I don't think you can do that from within pl/pgsql. You'd probably need a
> > function in pl/tclu or c.
> Or pl/perlu! (Sorry, had to say it).

I thought perlu was added after 7.1? I considered mentioning it, but
realized that it wouldn't help if it wasn't there yet.


From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: pl/sh (was Re: calling a shell script from pl/pgsql)
Date: 2001-09-10 18:24:31
Message-ID: Pine.BSO.4.10.10109101423360.17071-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On Mon, 10 Sep 2001, Stephan Szabo wrote:

>
> On Mon, 10 Sep 2001, Alex Pilosov wrote:
>
> > On Mon, 10 Sep 2001, Stephan Szabo wrote:
> >
> > > On Mon, 10 Sep 2001, Jeff Barrett wrote:
> > >
> > > > How can I call a shell script from within a pl/pgsql function that is called
> > > > as from a trigger. I do not want to interact with the script I just want it
> > > > to run. I do want the trigger to wait for the script it called to complete
> > > > before returning a value.
> > > >
> > > > Any ideas would be greatly appreciated.
> > >
> > > I don't think you can do that from within pl/pgsql. You'd probably need a
> > > function in pl/tclu or c.
> > Or pl/perlu! (Sorry, had to say it).
>
> I thought perlu was added after 7.1? I considered mentioning it, but
> realized that it wouldn't help if it wasn't there yet.
Sorry, my fault, I thought pl/tclu is also a new language, but it
apparently is in 7.1...Yes, for existing postgres, its pltclu or C,
sorry :)

-alex


From: clayton cottingham <drfrog(at)smartt(dot)com>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Jeff Barrett <jbarrett(at)familynetwork(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-10 18:44:33
Message-ID: 3B9D0A11.CCD5C785@smartt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Stephan Szabo wrote:
>
> On Mon, 10 Sep 2001, Jeff Barrett wrote:
>
> > How can I call a shell script from within a pl/pgsql function that is called
> > as from a trigger. I do not want to interact with the script I just want it
> > to run. I do want the trigger to wait for the script it called to complete
> > before returning a value.
> >
> > Any ideas would be greatly appreciated.
>
> I don't think you can do that from within pl/pgsql. You'd probably need a
> function in pl/tclu or c.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

if its typical perl you should be able to
use backticks
my $system=`date`;

$system should be set to the date

or if you dont need any data back as you say

then just

system('date');


From: "Jeff Barrett" <jbarrett(at)familynetwork(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-10 19:15:50
Message-ID: 9nj3od$1u4c$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Thanks for the suggestions.

I am running 7.1.2 and going to 7.1.3 soon.

If I use pl/tclu or pl/perlu I can call this executable from within the
code?

I have a signifigant limitation, I cannot duplicate the action of the
programs I want to call in a program I write within postgres, I need to call
the executable (In this one case it is a shell script but I have others
where it is a binary).

I cannot find the pl/sh module. The google links that came up brought me to
pages that no longer exist on postgresql.org. I will have to look around
some more.

Thanks for the advice... great help!

Jeff Barrett

"Jeff Barrett" <jbarrett(at)familynetwork(dot)com> wrote in message
news:9nip2p$1s5o$1(at)news(dot)tht(dot)net(dot)(dot)(dot)
> How can I call a shell script from within a pl/pgsql function that is
called
> as from a trigger. I do not want to interact with the script I just want
it
> to run. I do want the trigger to wait for the script it called to complete
> before returning a value.
>
> Any ideas would be greatly appreciated.
>
> Thanks,
>
> Jeff Barrett
>
>


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Alex Pilosov <alex(at)pilosoft(dot)com>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, Jeff Barrett <jbarrett(at)familynetwork(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: pl/sh (was Re: calling a shell script from pl/pgsql)
Date: 2001-09-10 19:26:40
Message-ID: Pine.LNX.4.30.0109102121580.680-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Alex Pilosov writes:

> Actually, I remember that Jan once mentioned something about pl/SH. I
> don't know what's the status of it?

http://webmail.postgresql.org/~petere/plsh.html

It's a toy project of mine. It's usable, but there are probably some
portability problems.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter


From: Larry Rosenman <ler(at)lerctr(dot)org>
To: Jeff Barrett <jbarrett(at)familynetwork(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-10 19:49:58
Message-ID: 20010910144958.B26527@lerami.lerctr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

* Jeff Barrett <jbarrett(at)familynetwork(dot)com> [010910 14:48]:
> Thanks for the suggestions.
>
> I am running 7.1.2 and going to 7.1.3 soon.
>
> If I use pl/tclu or pl/perlu I can call this executable from within the
> code?
>
> I have a signifigant limitation, I cannot duplicate the action of the
> programs I want to call in a program I write within postgres, I need to call
> the executable (In this one case it is a shell script but I have others
> where it is a binary).
>
> I cannot find the pl/sh module. The google links that came up brought me to
> pages that no longer exist on postgresql.org. I will have to look around
> some more.
I've reported the missing pages to the postgresql.org webmaster.

>
> Thanks for the advice... great help!
>
> Jeff Barrett
>
> "Jeff Barrett" <jbarrett(at)familynetwork(dot)com> wrote in message
> news:9nip2p$1s5o$1(at)news(dot)tht(dot)net(dot)(dot)(dot)
> > How can I call a shell script from within a pl/pgsql function that is
> called
> > as from a trigger. I do not want to interact with the script I just want
> it
> > to run. I do want the trigger to wait for the script it called to complete
> > before returning a value.
> >
> > Any ideas would be greatly appreciated.
> >
> > Thanks,
> >
> > Jeff Barrett
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler(at)lerctr(dot)org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749


From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Jeff Barrett <jbarrett(at)familynetwork(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: calling a shell script from pl/pgsql
Date: 2001-09-11 07:08:31
Message-ID: 200109110708.f8B78VV01263@saturn.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Jeff Barrett wrote:
> Thanks for the suggestions.
>
> I am running 7.1.2 and going to 7.1.3 soon.
>
> If I use pl/tclu or pl/perlu I can call this executable from within the
> code?
>
> I have a signifigant limitation, I cannot duplicate the action of the
> programs I want to call in a program I write within postgres, I need to call
> the executable (In this one case it is a shell script but I have others
> where it is a binary).

That's kind of a fuzzy explanation. If this "action" of your
programs in any way affects data, that should be part of the
triggers transaction, then what you want to do is broken by
design.

In detail, if the external program you're calling from the
trigger connects to the database, updates it and terminates,
the transaction that fired the trigger can still rollback,
discarding all changes that caused the trigger to get fired.
Thus, the database should look like the trigger never got
fired - but how do you undo the changes of your external
program? It connected to the database, did it's updates,
committed and terminated. You'll have no chance to undo that.

So if you really intend to do what it smells like, you're
better off moving all the "external program"s logic into some
function inside of the database, and call it from the
external program as well as the trigger.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com