pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
calling a shell script from pl/pgsql
7+ messages / 5 participants
[nested] [flat]

* calling a shell script from pl/pgsql
@ 2001-09-10 16:14 Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 17:22 ` Re: calling a shell script from pl/pgsql Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2001-09-10 19:15 ` Re: calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Jeff Barrett @ 2001-09-10 16:14 UTC (permalink / raw)
  To: 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





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-09-10 17:22 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2001-09-10 17:51   ` Re: calling a shell script from pl/pgsql Larry Rosenman <ler@lerctr.org>
  2001-09-10 18:44   ` Re: calling a shell script from pl/pgsql clayton cottingham <drfrog@smartt.com>
  1 sibling, 2 replies; 7+ messages in thread

From: Stephan Szabo @ 2001-09-10 17:22 UTC (permalink / raw)
  To: Jeff Barrett <jbarrett@familynetwork.com>; +Cc: 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.





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 17:22 ` Re: calling a shell script from pl/pgsql Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2001-09-10 17:51   ` Larry Rosenman <ler@lerctr.org>
  1 sibling, 0 replies; 7+ messages in thread

From: Larry Rosenman @ 2001-09-10 17:51 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: Jeff Barrett <jbarrett@familynetwork.com>; pgsql-sql

* Stephan Szabo <sszabo@megazone23.bigpanda.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@postgresql.org
> 

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 17:22 ` Re: calling a shell script from pl/pgsql Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2001-09-10 18:44   ` clayton cottingham <drfrog@smartt.com>
  1 sibling, 0 replies; 7+ messages in thread

From: clayton cottingham @ 2001-09-10 18:44 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: Jeff Barrett <jbarrett@familynetwork.com>; 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@postgresql.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');



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-09-10 19:15 ` Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 19:49   ` Re: calling a shell script from pl/pgsql Larry Rosenman <ler@lerctr.org>
  2001-09-11 07:08   ` Re: calling a shell script from pl/pgsql Jan Wieck <JanWieck@Yahoo.com>
  1 sibling, 2 replies; 7+ messages in thread

From: Jeff Barrett @ 2001-09-10 19:15 UTC (permalink / raw)
  To: 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@familynetwork.com> wrote in message
news:9nip2p$1s5o$1@news.tht.net...
> 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
>
>





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 19:15 ` Re: calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-09-10 19:49   ` Larry Rosenman <ler@lerctr.org>
  1 sibling, 0 replies; 7+ messages in thread

From: Larry Rosenman @ 2001-09-10 19:49 UTC (permalink / raw)
  To: Jeff Barrett <jbarrett@familynetwork.com>; +Cc: pgsql-sql

* Jeff Barrett <jbarrett@familynetwork.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@familynetwork.com> wrote in message
> news:9nip2p$1s5o$1@news.tht.net...
> > 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@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: calling a shell script from pl/pgsql
  2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
  2001-09-10 19:15 ` Re: calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
@ 2001-09-11 07:08   ` Jan Wieck <JanWieck@Yahoo.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Jan Wieck @ 2001-09-11 07:08 UTC (permalink / raw)
  To: Jeff Barrett <jbarrett@familynetwork.com>; +Cc: 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@Yahoo.com #



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




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2001-09-11 07:08 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-10 16:14 calling a shell script from pl/pgsql Jeff Barrett <jbarrett@familynetwork.com>
2001-09-10 17:22 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-09-10 17:51   ` Larry Rosenman <ler@lerctr.org>
2001-09-10 18:44   ` clayton cottingham <drfrog@smartt.com>
2001-09-10 19:15 ` Jeff Barrett <jbarrett@familynetwork.com>
2001-09-10 19:49   ` Larry Rosenman <ler@lerctr.org>
2001-09-11 07:08   ` Jan Wieck <JanWieck@Yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox