Calling Operating System Commands from PL/SQL using java
Calling Operating System Commands from PL/SQL - The Java Way
wlth help of given thread link,
Calling OS Commands from Plsql
but i had user privilege problem
Declare
x Varchar2(2000);
Begin
x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
DBMS_OUTPUT.Put_Line(x);
End;
o/p;
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
i done the grant privillage also
part
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
dbms_java.grant_permission('
abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
again
get
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
same error;
Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back.
Similar Messages
-
Calling Operating system command from PL/SQL programs
Hi
Is there any way we call the unix shell script from PL/SQL procedure/functionsIn 10g, it is possible.
BEGIN
dbms_scheduler.create_job(job_name => 'myjob',
job_type => 'executable',
job_action => '/app/oracle/x.sh',
enabled => TRUE,
auto_drop => TRUE);
END;
SQL> exec dbms_scheduler.run_job('myjob');
Documentation:
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#sthref6596
-aijaz -
How to: execute operating system commands from PL/SQL
System: IBM pSeries AIX
Oracle: 11g Enterprise
Is there a quick way to execute operating system commands from PL/SQL?
Without creating a JAVA class....
I need to execute a Loader script.
I want to do this from within PL/SQL.
I need to to do 4 things.
Three require SQL scripts.
The fourth is SQL*Loader.
The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
Is there way to do all this from within ONE PL/SQL SCRIPT ??
Just let me know.Is there a quick way to execute operating system commands from PL/SQL?
NO
Without creating a JAVA class....
I need to execute a Loader script.
I want to do this from within PL/SQL.
WHY ON EARTH, such action will create a new connection and become a resource hog?
I need to to do 4 things.
Three require SQL scripts.
The fourth is SQL*Loader.
The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
Which is perfect for the purpose.
Is there way to do all this from within ONE PL/SQL SCRIPT ??
Just let me know.
NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
Sybrand Bakker
Senior Oracle DBA -
How to call Operating System commands / external programs from within APEX
Hi,
Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
Any pointers will be greatly appreciated.
Thanks & Regards,Hi Guys,
I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
sqlplusw.exe user/password@database @script1.sql
sqlplusw.exe user/password@database @script2.sql
sqlplusw.exe user/password@database @script3.sql
sqlplusw.exe user/password@database @script4.sql
What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
Any help will be greatly appreciated.
Thanks & Regards, -
Executing a Operating System command from Stored Procedure ??
I want to execute a Operating System command from a PL/SQL Stored Procedure, can anyone suggest me how can I do this ??
I am on Sun-Solaris with Oracle 8.1.7 database.
Please do email me at [email protected]
Thanks in Advance,
Ramesh L.Are you using a webserver? If so, you could make your operating system script into a CGI program, then execute it from pl/sql using utl_http.request.
-
Is it possible to call operating system command after file receive?
Hi expert,
I'm trying to call operating system command after file receive comm.channel receive a txt file.
operating system command uses txt file name as parameter.
Is it possible? How?
Thanks.Hi,
It should be possible, actually we have two options that are
1.RUN OS command before message processing
2.RUN OS command after message processing.
So you can give the commands in the RUN OS command after message processing.
Check this links for more info
http://wiki.sdn.sap.com/wiki/display/XI/SAP%20XI%20File%20Adapter%20OS%20Command%20Line%20Feature
http://help.sap.com/saphelp_nwpi71/helpdata/en/44/556cb799c93677e10000000a114a6b/content.htm
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417200)ID1690747750DB11724434094963199241End?blog=/pub/wlg/10392
Regards
Ramesh -
Call operating system services from Jdeveloper
How can i call operating system services from Jdeveloper ?
nullWe do not use JDeveloper but use external procedures/routines called from the database. Then you can call a database procedure to an operating system task.
Linda -
How to execute Operating System commands from Stored procedure.
Any help on how to execute Operating System commands from stored procedures will be appreciated.
Nanditha.Search the forums for 'External Procedure' and you will find example code that has been posted before.
-
Error while calling .svc web service from pl/sql using utl_dbws
Hello Folks,
I am calling a .svc web service from pl/sql using utl_dbws and encountering the following error
javax.xml.rpc.soap.SOAPFaultException: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
Can you help me find what am I doing wrong?
Thanks
RkHi,
Here are the details
1. What version?
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
2. What error message ... we need the full and complete error stack not your interpretation of it.
ORA-29532: Java call terminated by uncaught Java exception: javax.xml.rpc.soap.SOAPFaultException: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Messag
3. "I am calling means what?" We need the full and complete statement showing the values of all parameters.
The input to the web-service is a xmltype containing address information and the web-service returns a string
CREATE OR REPLACE FUNCTION get_id
RETURN VARCHAR2
AS
l_service UTL_DBWS.service;
l_call UTL_DBWS.CALL;
l_wsdl_url VARCHAR2 (32767);
l_namespace VARCHAR2 (32767);
l_service_qname UTL_DBWS.qname;
l_port_qname UTL_DBWS.qname;
l_operation_qname UTL_DBWS.qname;
l_xmltype_in SYS.XMLTYPE;
l_xmltype_out SYS.XMLTYPE;
l_return VARCHAR2 (32767);
BEGIN
l_wsdl_url := 'http://test.com/test.svc?wsdl';
l_namespace := 'http://test.org/';
l_service_qname := UTL_DBWS.to_qname (l_namespace, 'SName');
l_port_qname := UTL_DBWS.to_qname (l_namespace, 'BasicHttpBinding_ISName');
l_operation_qname := UTL_DBWS.to_qname (l_namespace, 'Iden');
l_service :=
UTL_DBWS.create_service
(wsdl_document_location => urifactory.geturi
(l_wsdl_url),
service_name => l_service_qname
l_call :=
UTL_DBWS.create_call (service_handle => l_service,
port_name => l_port_qname,
operation_name => l_operation_qname
l_xmltype_in :=
SYS.XMLTYPE
('<IdenRequest xmlns:i="http://www.w3.org/XMLSchema-instance" xmlns="http://test.org/SNameIden.WCFService">
<address />
<zip>12345</zip>
<state>AA</state>
<street>W Test </street>
</address>
</IdenRequest>'
l_xmltype_out :=
UTL_DBWS.invoke (call_handle => l_call,
request => l_xmltype_in);
UTL_DBWS.release_call (call_handle => l_call);
UTL_DBWS.release_service (service_handle => l_service);
l_return := l_xmltype_out.EXTRACT ('//Iden/text()').getstringval();
RETURN l_return;
END;
/ -
How to call operating system commands?
Can we call OS commands from JAVA?
I am trying to call lpr/lp commands from JAVA.
Can anybody guide me where to search for this information.
Thanks in advance
SriniThanks for you all for this information. I will try this....Your information greatly helped me to go forward...
-
File Deletion from PL/SQL using Java
I'm able to delete a file on the OS from PL/SQL by calling a java class. But there is a problem if I am trying to delete any file located on any machine othere than the one on which the Database is hosted.
Can anyone tell me how delete a file which is on anothere machin using PL/SQL with Java ?You can use a FTP Call: http://www.savarese.org/oro/software/NetComponents.html
-
Calling a WCF service from pl sql using a scheduler.
Hi
I am completely new to everything pl sql related. Right now, I need to call a WCF service method that returns a dataset. Then i need to take that dataset and insert the data into a table in the database. I want to do this by having a scheduler be called once a day.
Does anyone have any code, examples etc?
thanksAnd WCF stands for what? In what version of the product?
First rule for someone new ... don't make the assumption that we can look over your shoulder or read your mind.
What you seem to want is the built-in scheduler. The docs are at http://tahiti.oracle.com.
Demos are at:
http://www.psoug.org/reference/dbms_scheduler.html -
O/s commands from PL/SQL
hi all..
i want to execute operating system commands from PL/SQL..
particulary imp command....
i have used the f/wg approach but while i execute the imp command it does not responds me any output..
I have to kill the process from o/s.
prodn is my user
--AS SYS user
begin
dbms_java.grant_permission( 'PRODN',
'SYS:java.io.FilePermission',
'/oracle/product/9.2.0/bin/imp',
'execute' );
dbms_java.grant_permission
('PRODN',
'java.lang.RuntimePermission',
'writeFileDescriptor' );
end;
---------------------------------AS PRODN user
create or replace and compile
java source named "Util"
as
import java.io.*;
import java.lang.*;
public class Util extends Object
public static int RunThis(String args)
Runtime rt = Runtime.getRuntime();
int rc = -1;
try
Process p = rt.exec(args);
int bufSize = 4096;
BufferedInputStream bis = new BufferedInputStream(p.getInputStream(),
bufSize);
int len;
byte buffer[] = new byte[bufSize];
// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);
rc = p.waitFor();
catch (Exception e)
e.printStackTrace();
rc = -1;
finally
return rc;
create or replace
function RUN_CMD(p_cmd in varchar2) return number
as
language java
name 'Util.RunThis(java.lang.String) return integer';
create or replace procedure RC(p_cmd in varchar2)
as
x number;
begin
x := run_cmd(p_cmd);
end;
i executed the command as follows in sql>
BEGIN
rc('/oracle/product/9.2.0/bin/imp tim/tim file=/home/oracle/vas4359.dmp log
=log1.log');
END;
it runs fine creates log1.log in / home/oracle but there is no output in
log1.log file.
I have to kill the process as follows after which sql> displays me :
"PL/SQL procedure successfully completed."
[oracle@msebdb oracle]$ ps aux|grep imp
oracle 20052 0.0 0.2 12732 4328 ? S 11:57 0:00 /oracle/product/
.2.0/bin/imp file=/home/oracle/vas4359.dmp log=log1.log
oracle 20102 0.0 0.0 3692 652 pts/2 S 12:03 0:00 grep imp
Note:There is no tim user.. i just want to get error in my log file..
my further steps are to read this log file and send email/notifications to users.
my main program is as f/ws:
/*imp and check log file*/
create or replace procedure abc
as
v_exists boolean;
v_exists_log boolean;
ex_open BOOLEAN;
flen NUMBER;
bsize NUMBER;
vInHandle_open utl_file.file_type;
vInHandle_open_log utl_file.file_type;
v_filelog utl_file.file_type;
v_fl utl_file.file_type;
v_pth varchar2(60);
v_fnm varchar2(60);
v_file_exists varchar2(60);
v_logline varchar2(30) ;
v_search varchar2(30) :='ORA-';
vNewLine VARCHAR2(32767);
cursor c_fname is
select full_pth ,f_name from upld_file_t where f_name in
(select f_name from tbl_file_nm where typ_file='D' AND DEL_FLG='N');
BEGIN
for v_sec in c_fname
loop
utl_file.fgetattr(LOCATION=>'ORALOAD',
FILENAME=>v_sec.f_name,
FEXISTS=>v_exists,
FILE_LENGTH=> flen,
BLOCK_SIZE=>bsize);
if v_exists
THEN
dbms_output.put_line('File Exists' || v_sec.f_name);
v_file_exists:=v_sec.f_name;
--dbms_output.put_line('v_file_exists ' || v_file_exists);
dbms_output.put_line('File Length: ' || TO_CHAR(flen));
dbms_output.put_line('Block Size: ' || TO_CHAR(bsize));
dbms_output.put_line(' before file open');
vInHandle_open := utl_file.fopen('ORALOAD',v_sec.f_name,'R',32767);
-- dbms_output.put_line(' after file open');
-- do whater with teh file data
v_fl:=utl_file.fopen('ORALOAD','v_sec.f_name','W');
dbms_output.put_line('v_sec.f_name');
IF utl_file.is_open(vInHandle_open)
THEN
/*if log file exists..*/
utl_file.fgetattr(LOCATION=>'ORALOAD',
FILENAME=>v_sec.f_name||'.log',
FEXISTS=>v_exists_log,
FILE_LENGTH=> flen,
BLOCK_SIZE=>bsize);
if v_exists_log
then
dbms_output.put_line('file' ||v_sec.f_name||'.log');
v_filelog :=utl_file.fopen('ORALOAD',v_sec.f_name||'.log','W',32767);
LOOP
BEGIN
UTL_FILE.PUT(v_filelog,'ORA-');
exit;
END;
END LOOP;
else
dbms_output.put_line('File not found' || v_sec.f_name);
END IF;
UTL_FILE.fclose(v_filelog);
dbms_output.put_line('Closed File ' || v_sec.f_name|| '.log');
END IF;
/*imp THE FILE and read log file*/
utl_file.fgetattr(LOCATION=>'ORALOAD',
FILENAME=>v_sec.f_name||'.log',
FEXISTS=>v_exists_log,
FILE_LENGTH=> flen,
BLOCK_SIZE=>bsize);
if v_exists_log
then
dbms_output.put_line('file' ||v_sec.f_name||'.log');
v_filelog :=utl_file.fopen('ORALOAD',v_sec.f_name||'.log','R',32767);
LOOP
BEGIN
UTL_FILE.get_line(v_filelog,v_logline);
if v_logline = v_search then
dbms_output.put_line(v_logline);
end if;
UTL_FILE.fclose(v_filelog);
dbms_output.put_line('Closed File ' || v_sec.f_name|| '.log');
exit;
END;
END LOOP;
else
dbms_output.put_line('File not found' || v_sec.f_name);
END IF;
END IF;
END LOOP;
--close the curosr .. check this
EXCEPTION
WHEN UTL_FILE.ACCESS_DENIED THEN
DBMS_OUTPUT.PUT_LINE('No Access!!!');
when others then
dbms_output.put_line('ERROR (open_file) => '||sqlcode);
dbms_output.put_line('MSG (open_file) => '||sqlerrm);
end;Hi,
You might have better luck in the PL/SQL or Java forums. They are located here:
PL/SQL: PL/SQL
Java: http://forums.oracle.com/forums/forum.jsp?forum=99
Good luck,
Mark -
OS command from PL/SQL code
Is there any way of running on OS (Operating System) command from SQL or PL/SQL. i.e. calling an executable from a trigger.
Is there any way of running on OS (Operating System) command from >SQL or PL/SQL. i.e. calling an executable from a trigger. Ashis,
Here's an example of a simple piece of Java you can create using SQL*Plus:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "RuntimeExample" AS public class RuntimeExample {
public static String runNotepad() {
String returnValue = null;
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec("notepad.exe");
returnValue = p.toString();
} catch (Exception e) {
System.out.println("Exception calling Runtime.exec()->" + e);
/* You can get creative here and
1) Use p.waitFor() to block while the process is running,
2) Send the command to be executed as a parameter to the method, etc. */
return returnValue;
CREATE OR REPLACE FUNCTION runNotepad RETURN VARCHAR2 IS
LANGUAGE JAVA NAME 'RuntimeExample.runNotepad() return java.lang.String';
DECLARE
my_varchar2 VARCHAR2(64);
BEGIN
my_varchar2 := runnotepad;
DBMS_OUTPUT.PUT_LINE(my_varchar2);
END;
Hope this helps,
-Dan
http://www.compuware.com/products/numega/dbpartner/dbpordebug.htm
Debug Java in the Oracle Database -
Execute external operating system command
Hi Friends,
I have a requirement to run a script file with extention '.PL' on the application server using ABAP.
i have sample how to run it in XI.
XI3.0 provides a very simple way of handling this using the "Operating System Command" in the File Adapter.
I post my output file in the following folder,
/usr/sap/sapout/test/
The shell script is available in the following path,
/usr/sap/bin/convert.pl
The figure below explains as to how we call the shell script using "Operating System Command".
File Acess parameters
Target Directory = /usr/sap/sapout/test/
File Name Scheme = TestOutput.txt
Processing Parameters
File Construction Mode = Add Time Stamp
File Type = Binary
Operating System Command = /usr/sap/bin/convert.pl %F
I have to do the same thing in ABAP as it has been done for XI as mentioned in the above example.
My operating system is UNIX.
If any one can give me a sample it would be really helpful to me.
Thanks in advance,
Arundhathi.Hi Arundhati,
You can run operating system commands from ABAP.
e.g. If you want to change UNIX right for any file, you can use following code.
lv_ucomm = 'chmod a+rwx 123.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_ucomm.
whatever command you provide in Field parameter ( lv_ucomm in the above case ), ABAP run that command at operating system level.
In your case, you can provide command in lv_ucomm to run script at operating system level.
Hope it will help you.
Regards,
Naren
Maybe you are looking for
-
E-mail going into trash folder instead of the normal destination
all of a sudden this started about 3 weeks ago e-mails were going into the trash the thing about it is I can't forward important mail to my friends etc from there == This happened == Every time Firefox opened == about 3 weeks ago
-
Hi people! I was just contemplating some question about arrays that I had this morning. Well, my question is about memory allocation. If I declare a new array of say 50 integers and then use it then declare another array of 30 integers using the same
-
Hi, i need help yesterday my lap was working good, but after lunch i try turn on, and i cant see nothing on my screen is dark just the ligth of the button of power my model is a toshiba U405-S2824, please help me! i opened my computer and everything
-
Hello My videos are encoded with a resolution of 640x480, but the aspect ratio must be 16:9, so I need to scale my videos to 848x480. This is my code: var ratioCorrection:LayoutMetadata = new LayoutMetadata(); ratioCorrection.width = 848; ratioCorrec
-
Sites for UI creation in Photoshop...
Looking for good sites for UI creation in Photoshop. I already have PSDTuts just wanted some other suggestions. Thanks!