Calling a perl script from stored procedure
Can anyone tell me how to call/run a perl script from a stored procedure? If you have a sample code, please include it.
Thanks in advance
If you have a web server setup that runs perl, you can do this by using the utl_http package...Here is some code I use to run a perl script and print the results to a web page on our site.
The in_URL parameter is the address of the perl code(i.e. http://website/path/perlscript?param1=value1¶m2=value2 etc)
PROCEDURE call_perl(in_URL VARCHAR2) IS
/* This is setup to allow a perl program to be submitted as a batch program
using the standard Portal batch program.
Sometimes these jobs take a long time to run, so the timeout value must
be set to a large value. The default timeout is 60 seconds, which is not long enough. */
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
BEGIN
req := utl_http.begin_request(replace(utl_url.escape(replace(in_URL,'%3A',':')),CHR(13)));
utl_http.set_transfer_timeout(req, 18000); -- Set timeout to 5 hours for this specific request.
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, value, TRUE);
htp.p(value);
END LOOP;
utl_http.end_response(resp);
EXCEPTION WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
WHEN utl_http.init_failed THEN
htp.p('INIT FAILED');
WHEN utl_http.request_failed THEN
htp.p('REQUEST FAILED');
htp.p(NVL(utl_http.get_detailed_sqlerrm,' No more detail available.'));
END;
If you don't have a web server setup, I don't know offhand how you could do this.
Laurel
Similar Messages
-
How to call a perl script from an apple script
Hi All,
How to Call a perl Script from an apple script.
Pls Give Your comments.
Thanx & Regards,
EstherApplescript to call a perl script named "/tmp/x.pl" passing an argument "world"
do shell script "/usr/bin/perl /tmp/x.pl world"
or if the script is given the executable atttribute (chmod +x /tmp/x.pl),
do shell script "/tmp/x.pl world"
Perl script "/tmp/x.pl" that prints a string using a passed argument
#!/usr/bin/perl
print "Hello $ARGV[$1]\n"; -
Hi guys,
I am developing an online ticket booking system.
i have come toa point where i need to call a perl script from JSP.
please let me know how to do it.
Basically, i need to call a function in perl script from JSP in order to encrypt my information.
Any help is appreciated.
Thanks in advance.
Chintan ShahI haven't done this myself, but it seems like it is possible in Tomcat.
You can configure Tomcat to handle .cgi calls (it does this via a CGI servlet)
http://www.ftponline.com/javapro/2003_03/online/perl_teden_03_18_03/
http://tomcat.apache.org/tomcat-5.0-doc/cgi-howto.html
Once this is set up, theoretically you should be able to then use requestdispatcher and forward/include a cgi script to invoke the perl.
I don't know if you are using Tomcat or not though... :-) -
Calling shell script from stored procedure.
Hi Everybody,
Could anyone tell me how to call a shell script from a stored procedure.
Thanks,
VasuYou would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
Justin -
Calling a Perl script from a BSP application
Hi all,
Is it possible to call a Perl program that resides on a different server from a BSP application. If so, how do I do it.
Thanks,
Shiraz.If I understand correctly what the script does then when you type the script by itself into the webbrowser do you get a response? If it works that way then you can quite easily use something like this:
<htmlb:gridLayout columnSize = "1"
rowSize = "1"
height = "600"
width = "100%" >
<htmlb:gridLayoutCell columnIndex = "1"
rowIndex = "1" >
<phtmlb:matrix width = "100%"
height = "100%" >
<phtmlb:matrixCell col = "1"
row = "1" />
<iframe id="MyIFrame" src="<%= lv_url %>" border="0" width="100%" height="100%" frameborder="0" />
</phtmlb:matrix>
</htmlb:gridLayoutCell>
</htmlb:gridLayout>
See: is it possible to define xhtml:tabscript width by using %
Just give your perl script as the URL for the iframe. Again this only works if calling the perl script in the browser works. -
File Ownership while executing sql script from stored procedure
We have a test_command.sql script which is spooling the result into a file. From database we have one Store Procedure(run_sql) which is
calling and executing the .sql script.
When we are calling the sql script directly from the database, i e SQL > @/dccops/test_command.sql it is creating the
file under the Ownership of OS user which is connected to the system.
The problem we are facing is when we are executing the stored procedure i e exec run_sql(), the file is creating under
Oracle User.
Could u please suggest me a solution inorder to create the output file under the user who is logged to the OS.First of all, your usage of IM speak is NOT appreciated. Please do not address anyone as if they were a 12-year old.
'Our Applcation is in C. So we have to call the procedure to run the sql script.'
This is just utter nonsense!
Oracle has Pro*C which allows Embedded SQL in C. There is also OCI (Oracle Call Interface) to call Oracle directly in C, and there is OCCI, to do the same in C++.
Apart from that, Oracle has Ole DB for Windows platforms, to allow for a .NET compatible interface to Oracle.
There is NO NEED AT ALL to call PL/SQL to run a SQL script.
Sybrand Bakker
Senior Oracle DBA -
Running a sql script from stored procedure
Hi everyone!
Has anybody tell me how to execute a sql script from a stored
procedure!
Thanks in advance!
Sasa>
Hi everyone!
Has anybody tell me how to execute a .sql file from a stored
procedure!
Thanks in advance!
Sasa Sorry, a .sql file!! -
Running Unix script from stored procedure
At present, I run a unix script to export my data for backup using telnet. I would like my users to run the commands on their own without my help. My users do not know telnet (they have no IT knowledge). So, I plan to create a form using Developer/2000 and let them run the procedure thru a stored procedure.But, my problem is how can a stored procedure call a unix script?
Hi,
solution, used by me.
Create a stored procedure that produces a text file with utl_file. The content of the file is the script you want to execute on your Unix box.
On your Unix Box write a shell script that scans the utl_file_dir for Files. If a file is in, chmod 744 to grnt execute rights to it and execute it.
I have a example if you want.
Start the script with crontab or let it loop with a sleep inside.
HTH
Detlev -
Can I call a perl script from a rule?
Hi experts.
I have a need to map characters
� -> a
� -> o
� -> a
� -> e
� -> u and so on..
to build an email address from peoples names.
looking at what XPRESS functions are available it would take a month to write. The manual warns against using javascript, so my options are limited.
perl seems a natural but is it possible?Guys,
Not being a java-programmer i still like to share this piece of code that will solve the initial Scandinavian Chars -> Non-Scandi ones...
I wrote a quick static java method that does the trick.
package se.inserve;
import java.util.regex.*;
public final class Utils {
public static final String code_id = "$Id: Inserve Utils,v 0.2 2005/07/23 21:10:16 A.A Exp $";
public static String replaceSweChar(String input) {
input = input.replaceAll("�", "a");
input = input.replaceAll("�", "A");
input = input.replaceAll("�", "a");
input = input.replaceAll("�", "A");
input = input.replaceAll("�", "o");
input = input.replaceAll("�", "O");
input = input.replaceAll("�", "e");
input = input.replaceAll("�","E");
return input;
The code is compiled as a class file, stuffed in a jar file (along with some additional junk) and thrown into the appserver's $WSHOME/WEB-INF/lib directory.
The method is invoked according to below. e.g via a Custom Tabbed User Form.
<Field name='global.email'>
<Display class='Label'>
<Property name='title' value='_FM_EMAIL'/>
</Display>
<Derivation>
<block trace='true'>
<defvar name='prefix'>
<concat>
<ref>global.firstname</ref>
<s>.</s>
<ref>global.lastname</ref>
</concat>
</defvar>
<cond>
<notnull>
<ref>prefix</ref>
</notnull>
<concat>
<invoke name='replaceSweChar' class='se.inserve.Utils'>
<ref>prefix</ref>
</invoke>
<s>@xyzcompany.com</s>
</concat>
</cond>
</block>
</Derivation>
</Field>
...Hope this helps someone.
/L -
Calling shell script from sql procedure
Hi gurus
Is it possible
1)to call a shell script from sql procedure
2)that shell script has to return one value
3)and again sql procedure(calling shell script) has to capture the return value.
please help me to write this scriptYou may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
. You will also need to :
1. Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
Shailender Mehta -
Calling perl script from labview
Hi,
I have a perl script and I would like to call the perl script from Labview
anyone can help me with that?
I used system exec but I'm getting an error.
Anyone have a working example like calling a simple perl script from Labview.
Thanks
SL OngHi,
Thanks for the reply from everyone.
The attached is my code to call Perl script and after calling this, I need to query the Perl Script by sending command like @help. Do they have a way to query the Perl script by sending command like @help and get the return result.
I think Joseph you are right, but how do I get the return result if I invoke it in a separate dos session.
SL Ong -
I am facing a problem in running a PERL script in JAVA in UNIX box..
I am able to call ther perlscript.
Perl script has
#! /usr/local/bin/perl
print "\nEnter Your Name :";
$name = <>;
print "\nYour Name is : $name\n";
exit 0;
Perl script request for the INPUT(name) .
My Java program is
File perlfile = new File("test.pl");
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("perl "+perlfile);
Here is the problem tat IT IS says error =2 ..What has to be the solution so tat i can CALL PERL SCRIPT as similiar to running it separatly in prompt { >perl test.pl }
PLEASE help me on this....In the PERL SCRIPT (test.pl)
LINE 1 : #! /usr/local/bin/perl
LINE 2 : print "\nEnter Your Name :"; .
LINE 3 : $name = <>;
LINE 4 : print "\nYour Name is : $name\n";
LINE 5 : exit 0;
When i run this script in perl test.pl in prompt (UNIX BOX), i am gettin the request for name "Enter Your Name:____ " but when i call this script from Java it doesn't request for name and moreover the process doesnt ends (use ctrl+c to come out of the process).When i come out forcefully it shows the ERROR=2.
My requirement is such tat need to call a PERL SCRIPT from java so tat java process give the control to PERL script and it will continue the process..
Sample scenario:
Java move a file and store it in a new FOLDER
MY perl script will read the file in new FOLDER.
here the perl script will get the file name for processing... My issue comes here .$name is not be prompted while calling thro java.. -
How to call external Perl routines from Pl/SQL - Urgent
Available software in the Test Environment:
1. Sun Unix 2.8
2. Oracle 8.1.7 ( 8i)
3. Perl 5
Iam trying to call/execute perl scripts from PL/SQL using the DEMO_RDBMS.mk. I am able to call C scripts from PL/SQL, but actually want to call Perl scripts.
The steps followed for for C are -
1. Create and compile a simple C program to execute a unix command (eg., touch a file).
2. Make a shared library of the above compiled program (object), i.e., load the compiled object module into a dynamic load library.
3. Declare the above library in Oracle using SQL*Plus.
4. Define a PL/SQL function or procedure to call the external routine.
5. Test the external routine.
The above steps run good for a C program, but step 2 fails when run for a Perl script.
When I tried to use the following command for step 2 -
make -f $ORACLE_HOME/rdbms/demo/demo_rdbms.mk extproc_callback \
SHARED_LIBNAME=cmd_lib.so \
OBJS=tst_cmd.pl
got the following error -
ld: fatal: file tst_cmd.pl: unknown file type.
ld: fatal: File processing errors. No output written t cmd_lib.so
*** Error code 1
This gives me an indication that demo_rdbms.mk does not understand/interpret Perl scripts. Going through the demo_rdbms.mk suggests the same.
My questions is - How do we call external Perl scripts/routines from PL/SQL ??
Do I have to get a different version of "demo_rdbms.mk" ?
PS: The perl scripts used above (tst_cmd.pl) is error free and works as intended in the unix environment.Iam trying to call/execute perl scripts from PL/SQL using the DEMO_RDBMS.mk. I am able to call C scripts from PL/SQL, but actually want to call Perl scripts. Well, C is a "compiler" language and Perl is interpreted. In a sense, C is not "scripts".
When I tried to use the following command for step 2 -
make -f $ORACLE_HOME/rdbms/demo/demo_rdbms.mk extproc_callback \
SHARED_LIBNAME=cmd_lib.so \
OBJS=tst_cmd.pl
got the following error -
ld: fatal: file tst_cmd.pl: unknown file type.
ld: fatal: File processing errors. No output written t cmd_lib.soI guess this compiles an extproc "stub" with your object file, generating an external procedure. So the object file really needs to be an object file :-)
My questions is - How do we call external Perl scripts/routines from PL/SQL ??I'd guess you need an embedded Perl interpreter in the external procedure.
Not much help though I'm afraid :-/
Cheers
Fredrik -
Calling perl script from PLSQL
Hi All,
I have created Java stored procedure and oracle function to execute the os commnad, this works fine for calling batch scripts but when i used same function to call perl script,
like how we call in batch script
perl <script name> the sql gets hanged.
Is it possible to call perl like this?
or is their any other way to call from plsql
Thanks ChandraAre you able to run that perl script at DOS command line?
Did you call the perl script directly from the java proc or you put the perl command line in a DOS .BAT scirpt and called that from the java proc? -
Shell script invoke from stored procedure
Hi All,
Can anyone tell me how to call UNIX SHELL SCRIPT from oracle stored procedure PL/SQL. Example with detailed explanation.
Please Share the needful.
Thanks in Advance
PricksHere, The example is given below, I want to invoke the Script which i mentioned like HERE INVOKE THE ABOVE SHELL SCRIPT in that place.
CREATE OR REPLACE PROCEDURE spwritelog
inFileName VARCHAR2,
inLogMsg VARCHAR2,
inLogLevel CHAR(1),
outRc OUT NUMBER
AS
tmpMsg VARCHAR2(255);
BEGIN
outRc := 0;
IF inLogLevel = 'X' THEN
tmpMsg := "echo `date +'%Y-%m-%d %H:%M:%S'` ' " || inLogMsg || "' >> " || inFileName;
HERE INVOKE THE ABOVE SHELL SCRIPT
ELSIF inLogLevel = "9" THEN
tmpMsg := "echo `date +'%Y-%m-%d %H:%M:%S'` ' " || inLogMsg || "' >> /tmp/spAllLog.err";
HERE INVOKE THE ABOVE SHELL SCRIPT
END IF;
EXCEPTION
WHEN OTHERS THEN
outRc:=SQLCODE;
END spwritelog;
Please correct the code and tell.......
please share the needful
Edited by: 866916 on Aug 19, 2011 5:38 PM
Maybe you are looking for
-
Copy file names into New Mail Message?
*I've been slowly teaching myself Applescript, and can't seem to find a way to do a few things. Basically what I'm trying to do is set up a script that will run when items are dropped into a folder on my FTP. I want the script to have a pop-up dialog
-
Hi, I am new to Applescript and after messing around with it have a few questions.
Firstly, I love applescript so far and have made an alarm clock, simple get weather app and applescript app that announces the time and date. i would like to be able to use this as a jarvis like combined app where i can have all of these built into o
-
Using Automator in place of Tether
+I posted this in another topic in reply to a question, but since I get asked this a lot I figured I'd give it a unique post.+ So, if you were one of the many hoping Apple would add the ability to shoot tethered directly from within Aperture, only to
-
An end user was able to manually change the wbs element in ML81N that differed from the one in the purchase order. This caused problem for FM and FI. Is there a way to make it so the wbs can't be changed in ML81N? Thanks in advance! Eric
-
How to dowload data in particular cell of designed excel sheet
hi everyone i want to dowload the data in a excel sheet, but this excel sheet is designed in such a format that i have download each field of internal table in a specified cell only , <b>gui_download</b> function module simply download the data in ex