- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- java procedure call os command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 09:37 PM
тАО04-27-2008 09:37 PM
database: oracle 10g
i want call os command in plsql,the method is that:
conn / as sysdba
SQL> EXEC DBMS_JAVA.grant_permission('TEST', 'java.io.FilePermission', '<
PL/SQL procedure successfully completed.
SQL> EXEC Dbms_Java.Grant_Permission('TEST', 'SYS:java.lang.RuntimePermission',
'writeFileDescriptor', '');
PL/SQL procedure successfully completed.
SQL> EXEC Dbms_Java.Grant_Permission('TEST', 'SYS:java.lang.RuntimePermission',
'readFileDescriptor', '');
PL/SQL procedure successfully completed.
conn test/test
SQL> create or replace and compile
2 java source named "Util"
3 as
4 import java.io.*;
5 import java.lang.*;
6 public class Util extends Object
7 {
8 public static int RunThis(String args)
9 {
10 Runtime rt = Runtime.getRuntime();
11 int rc = -1;
12 try
13 {
14 Process p = rt.exec(args);
15 int bufSize = 4096;
16 BufferedInputStream bis =
17 new BufferedInputStream(p.getInputStream(), bufSize);
18 int len;
19 byte buffer[] = new byte[bufSize];
20 while ((len = bis.read(buffer, 0, bufSize)) != -1)
21 System.out.write(buffer, 0, len);
22 rc = p.waitFor();
23 }
24 catch (Exception e)
25 {
26 e.printStackTrace();
27 rc = -1;
28 }
29 finally
30 {
31 return rc;
32 }
33 }
34 }
35 /
Java created.
SQL>
SQL>
SQL> create or replace
2 function RUN_CMD(p_cmd in varchar2) return number
3 as
4 language java
5 name 'Util.RunThis(java.lang.String) return integer';
6 /
Function created.
SQL>
SQL>
SQL> create or replace procedure RC(p_cmd in varchar2)
2 as
3 x number;
4 begin
5 x := run_cmd(p_cmd);
6 end;
7 /
Procedure created.
set serveroutput on
exec dbms_java.set_output(100000);
exec rc('show sys');
exec dbms_java.grant_permission( 'TEST', 'SYS:java.io.FilePermission', '<
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:280)
at java.security.AccessController.checkPermission(AccessController.java:429)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:528)
at oracle.aurora.rdbms.SecurityManagerImpl.checkPermission(SecurityManagerImpl.java:192)
at java.lang.SecurityManager.checkExec(SecurityManager.java:778)
at java.lang.Runtime.exec(Runtime.java:563)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at Util.RunThis(Util:11)
PL/SQL procedure successfully completed.
the procedure successfully completed,but the os command not be called,
thank you for help me!!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 10:29 PM
тАО04-27-2008 10:29 PM
Re: java procedure call os command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 12:12 AM
тАО04-28-2008 12:12 AM
Re: java procedure call os command
In a Unix environment these are programs and (shell/perl...) scripts. In a VMS environment these are images and DCL command procedures.
You can not execute a Unix shell command or a VMS DCL command. For example, a VMS command "show sys" can not be executed from Java.
Other examples are "ls -l *.txt" or "DIR/FULL *.TXT". Both will not work if run from Java for the same reasons: both require a shell or DCL to be activated.
As a workaround, you may be able to run the command as a one-line input to the shell/DCL. On Unix this can be done with "sh -c \"ls -l *.txt\"". On VMS you may get it to work with the GNV DCL.EXE wrapper "gnu:[bin]dcl.exe \"DIR/FULL *.TXT\"".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 07:47 AM
тАО04-28-2008 07:47 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2008 06:34 AM
тАО04-29-2008 06:34 AM
Re: java procedure call os command
i want to execute openvms command such as $delete a.com;1 in plsql program
example:
SQL>exec exec_cmd('delete a.com')
how can i do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2008 07:44 AM
тАО04-29-2008 07:44 AM
Re: java procedure call os command
and create dcl.com with
$ 'p1' 'p2' 'p3' 'p4' ...
Check my link for "works".
Wim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2008 10:31 PM
тАО04-30-2008 10:31 PM
Re: java procedure call os command
thank you,i had solved the problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2008 12:53 AM
тАО05-09-2008 12:53 AM
Re: java procedure call os command
DCL.COM
$create/dir dkb0:[oracle.zm]
SQL>exec rc('@dkb0:[oracle]dcl');
then the directory zm is created.
2.
DCL.COM
$run $1$dga3:[USERS.LY]RMCOEFINIT
$@DCL //the RMCOEFINIT.exe can be executed.
but
SQL>exec rc('@dkb0:[oracle]dcl');
the RMCOEFINIT.exe can't be executed.
how can i execute the exe file.