473,508 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run a unix or perl command in a trigger

Hi Postgres users,

I wonder to know if it is possible to launch a Perl program or a unix
comand in a trigger function.
I have tried to do that in a C trigger developed with the SPI function.
But my examples does not work and i don't have any error messages in the
postgres logfile.
So, i ask you your opinion and an example of code if your trigger works.

Regards,
Thierry Missimilly
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
1 3193
> I wonder to know if it is possible to launch a Perl program or a unix
comand in a trigger function.
I have tried to do that in a C trigger developed with the SPI function.
But my examples does not work and i don't have any error messages in the
postgres logfile.
So, i ask you your opinion and an example of code if your trigger works.


I guess I'm not sure what you mean by 'launch'. Do you need to query the
results?

Here's a plperlu function that runs an external shell script.

I've not tried it in a trigger, but it should work. This function
needs to be created as a superuser since it uses 'untrusted' perl.

It creates a security hole in that anyone who has write access to the
postgres user home directory can run ANYTHING.
--
Mike Nolan

create or replace function submit_batch(varchar, varchar)
returns varchar
security invoker
as '

# perl body goes here
# parameters: user ID
# batch id

$command = "/home/postgres/submit_batch.job "
.. "$_[0]" . " " . "$_[1]" ;

$x = system($command);

return $x;
' language plperlu;
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6528
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
2
5654
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info...
0
6425
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this...
8
2761
by: TonyHa | last post by:
Hello, Does any one have using Python to write a Unix "diff" command for Window? Tony Ha.
0
1658
by: niket patel | last post by:
Hi There is a unix server and and we access unix and perform its commond using exceed or ftp through dos. Now i want to create an application in Visual Studio C#.Net 2003 such that i can create...
2
1936
by: George Ter-Saakov | last post by:
Hi, Somehow i need to call perl script that is on another Unix machine form my C# code. The problem is that this perl script is executed form command line (no apache on that machine). Is...
2
6972
by: sunilsn | last post by:
Hi, I am newbie to perl, I hope you guys will help me resolve the challenge I am facing. I have a unix shell script on one UNIX machine say A, and a batch file on windows machine say B. Now I want...
223
7088
by: Pilcrow | last post by:
Given that UNIX, including networking, is almost entirely coded in C, how come so many things are almost impossible in ordinary C? Examples: Network and internet access, access to UNIX...
1
4031
by: KiSSFRo | last post by:
Hi all, I was wondering if someone could tell me which is the best command to use to run a unix command and to hide the error output from the shell. I'd also like to be able to tell if the...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.