威尼斯www.9778.com-威尼斯正版官方网站

oracle执行cmd的实现方法

日期:2020-01-16编辑作者:数据库

只是有二个精简的施行cmd命令方法: SQL host net user User accounts for

装了贰个oracle db11g,于是想试一下网络流传的在sqlplus中实行cmd的有的命令,也不知怎么的,没三个好用的,大概是英特网转来转去的转错了.然则有贰个简单易行的试行cmd命令方法:

//PC-ATQHJ4UG1SDA

__vmware_user__ admin Administrator ASPNET Guest IUSR_PC-ATQHJ4UG1SDA IWAM_PC-ATQHJ4UG1SDA SUPPORT_388945a0 The command completed successfully. unix或linux下用 ! command ======================补充====================== 网络的另三种方法: 1是利用msvcrt.dll 写一个c:/orac.sql 内容: Rem Rem oracmd.sql Rem Rem Run system commands via Oracle database servers Rem Rem Bugs to david@ngssoftware.com Rem CREATE OR REPLACE LIBRARY exec_shell AS 'C:/windows/system32/msvcrt.dll'; / show errors CREATE OR REPLACE PACKAGE oracmd IS PROCEDURE exec (cmdstring IN CHAR); end oracmd; / show errors CREATE OR REPLACE PACKAGE BODY oracmd IS PROCEDURE exec(cmdstring IN CHAR) IS EXTERNAL NAME "system" LIBRARY exec_shell LANGUAGE C; end oracmd; / show errors 然后C:/sqlplus /nolog SQL*Plus: Release 8.1.7.0.0

  • Production on Thu Jun 7 14:25:38 二零零四 (c卡塔尔(قطر‎ Copyright 二〇〇二 Oracle Corporation. All rights reserved. SQL connect system/manager@orcl (分别是客户名密码和sid卡塔尔 Connected. SQL @c:/orac.sql Library created. No errors. Package created. No errors. Package body created. No errors. SQL SQL exec oracmd.exec ('dir c:/oracle.txt'卡塔尔(قطر‎; 结果在自个儿本机现身 第 1 行现身错误: ORA-28595: Extproc 代理: DLL 路线无效 ORA-06512: 在 "SYSTEM.ORACMD", line 2 ORA-06512: 在 line 1 尚未得逞。 其次种办法 c:/1.sql 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; } } } c:/2.sql create or replace function RUN_CMz(p_cmd in varchar2) return number as language java name 'util.RunThis(java.lang.String) return integer'; c:/3.sql create or replace procedure RC(p_cmd in varChar) as x number; begin x := RUN_CMz(p_cmd卡塔尔(قطر‎; end; 登录上去后依旧是各类推行 SQL @c:/1.sql / @c:/2.sql / @c:/3.sql / variable x number; set serveroutput on; exec dbms_java.set_output(100000); grant javasyspriv to system; grant javauserpriv to system; exec :x:=run_cmz('ipconfig'卡塔尔国; 成功运维了命令 测量检验意况win二零零四+oracle11g

SQL> host net user

User accounts for PC-ATQHJ4UG1SDA


__vmware_user__          admin                    Administrator
ASPNET                   Guest                    IUSR_PC-ATQHJ4UG1SDA
IWAM_PC-ATQHJ4UG1SDA     SUPPORT_388945a0
The command completed successfully.

 

unix或linux下用

! command

======================补充======================

英特网的另二种办法:

1是利用msvcrt.dll

写一个c:orac.sql

内容:

Rem
Rem oracmd.sql
Rem
Rem Run system commands via Oracle database servers
Rem
Rem Bugs to [email protected]
Rem
CREATE OR REPLACE LIBRARY exec_shell AS
C:windowssystem32msvcrt.dll;
/
show errors
CREATE OR REPLACE PACKAGE oracmd IS
PROCEDURE exec (cmdstring IN CHAR);
end oracmd;
/
show errors
CREATE OR REPLACE PACKAGE BODY oracmd IS
PROCEDURE exec(cmdstring IN CHAR)
IS EXTERNAL
NAME "system" LIBRARY exec_shell
LANGUAGE C;
end oracmd;
/
show errors

然后C:>sqlplus /nolog
SQL*Plus: Release 8.1.7.0.0 - Production on Thu Jun 7 14:25:38 2001
(c) Copyright 2000 Oracle Corporation. All rights reserved.
SQL> connect system/[email protected] (分别是顾客名密码和sid卡塔尔(قطر‎
Connected.
SQL> @c:orac.sql
Library created.
No errors.
Package created.
No errors.
Package body created.
No errors.
SQL>
SQL> exec oracmd.exec (dir > c:oracle.txt);

结果在小编本机现身

第 1 行出现错误:
ORA-28595: Extproc 代理: DLL 路线无效
ORA-06512: 在 "SYSTEM.ORACMD", line 2
ORA-06512: 在 line 1

未曾成功。

第三种艺术

c:1.sql

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;
}
}
}

c:2.sql

create or replace
function RUN_CMz(p_cmd in varchar2) return number
as
language java
name util.RunThis(java.lang.String) return integer;

c:3.sql

create or replace procedure RC(p_cmd in varChar)
as
x number;
begin
x := RUN_CMz(p_cmd);
end;

登入上去后仍然为种种实践

SQL> @c:1.sql
        /

       @c:2.sql

       /

      @c:3.sql

      /

variable x number;

set serveroutput on;

exec dbms_java.set_output(100000);

grant javasyspriv to system;

grant javauserpriv to system;(网络的不二秘籍未有那风姿罗曼蒂克行,笔者不也许得逞,加上去能够)

exec :x:=run_cmz(ipconfig卡塔尔; 成功运维了指令

测量检验境况win2004+oracle11g

db11g,于是想试一下网络流传的在sqlplus中奉行cmd的部分命令,也不知怎么的,没三个好用的,或者是英特网转来转去的转错了....

本文由威尼斯www.9778.com发布于数据库,转载请注明出处:oracle执行cmd的实现方法

关键词:

Oracle行级锁的特殊用法简析威尼斯正版官方网站

威尼斯正版官方网站,Oracle有许多的锁,各种锁的效用是不一样的。下面重点介绍Oracle行级锁,Oracle行级锁只对用户...

详细>>

威尼斯正版官方网站oracle 删除重复数据

重复的数据可能有这样两种情况,第一种:表中只有某些字段一样,第二种是两行记录完全一样。 一、对于部分字段重...

详细>>

PLSQL Developer登录的默认密码介绍

Oracle 9i默认的用户 安装ORACLE12C时,若没有为下列用户重设密码,则其默认密码如下: 欢迎和大家交流技术相关问题:...

详细>>

JavaScript中的数据类型转换方法小结,javascript数据类型

摘要: 下文讲述使用sql脚本的方法判断字符串为大小写的方法分享,如下所示 实验环境:sqlserver 2008 R2 实现思路: 将字...

详细>>