System command from within PL/SQL on server ?

Hi
I know its a bit weird thought of executing an NT system command from within PL/SQL on server (UNIX).
Has anyone done something (silly me!) like it or knows any work-around to try something like it?
Thanks in advance.
Regards
Pravesh

Can you be more specific?
Generally to run system commands you utilize DBMS_PIPE to communicate with a listener on the platform that you're accessing. That listener picks up the pipe request and might either:
1. spawn a process to run the command
2. fork a process to run the command
3. run the command within its own application.
It sounds complex, but if review the DBMS_PIPE documentation and it's not too difficult -- presuming you know a language like C.
I believe there are other features in 8.1.5 and higher versions that enable you to run stored programs or COM objects...
Bill

Similar Messages

  • Executing OS command from within PL/SQL...

    Hi
    I would like to know if you can issue operating system command
    from within a PL/SQL block on Oracle Database(not developer
    2k) .Is there any built in package for the same ? Like a similar
    command is available in forms i.e HOST .
    Can anyone help please ?
    Thank You
    Cheers
    Raghavendra
    null

    The only documentation I have seen uses dbms_pipe which
    communicates with a host 3gl program, usually C, which in turn
    issues a call to the c function system(). You could also mimic
    these same actions without using dbms_pipe by using a extproc
    program linked to the database if you are running db version 8.0
    or above. See the pl/sql procedure manual for dbms_pipe examples.
    Raghavendra (guest) wrote:
    : Hi
    : I would like to know if you can issue operating system command
    : from within a PL/SQL block on Oracle Database(not developer
    : 2k) .Is there any built in package for the same ? Like a
    similar
    : command is available in forms i.e HOST .
    : Can anyone help please ?
    : Thank You
    : Cheers
    : Raghavendra
    null

  • 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.

  • Error when trying to truncate table from within PL/SQL

    Hello.....
    Does anyone know why I get an error when trying to execute the following command from within PL/SQL?
    truncate table event;
    The error is as follows:
    ORA-06550: line 20, column 14:
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.

    And as a DDL, it does a COMMIT just before it runs. Whether you want a COMMIT or not.
    And with all the locking and serialization issues associated with a DDL.

  • System Commands from Flex/Apollo

    Does anyone know if it's possible to run native system
    commands from within a Flex/Apollo application?
    In Java, I think you can do something like
    System.exec("command") - where you can run any command line
    application.

    I'm attempting to create a function which will run in the background of a Windows OS and will print the current window from a single keystroke. I want to use HookDll to do so, but have been unsuccessful in opening this file and viewing meaningful results.
    Any direction for the best approach to this problem is appreciated. However, my curiosity (and frustration) has been aroused over HookDll, so I would like to know how to decompile/recompile this file as well.
    I have tried using .Net Reflector, but it returns that HookDll.dll is not a .NET module. I have also used Hex Editor Neo to view the binary file and attempt to make sense of it.
    Not a scripting issue.
    There are dozens of utilities that can be downloaded that do this.
    Consider using Alt-PrtScr which prints the current Window with a single keystroke:
    http://windows.microsoft.com/en-us/windows/take-screen-capture-print-screen#take-screen-capture-print-screen=windows-8
    ¯\_(ツ)_/¯

  • 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

  • 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.

  • What is the trick to 'exec' UNIX commands from within IDM?

    Hellos...
    We need to change the permissions of a file which an IDM script writes.
    Basically I call this rule to write bytes to a file. The write method works but the exec fails.. I dont see permissions set to "666".
    <block trace='true'>
    <defvar name='retBuff'/>
    <invoke name='writeFileUtf8' class='com.waveset.util.Util'>
    <ref>fileName</ref>
    <ref>xmlData</ref>
    </invoke>
    <set name='retBuff'>
    <invoke name='exec' class='com.waveset.util.Util'>
    <concat>
    <s>chmod 666 </s>
    <ref>fileName</ref>
    </concat>
    </invoke>
    </set>
    </block>
    What is the correct method (or any way which works) to run shell commands from within IDM??????

    Ok. There is no 'trick' just an appreciation of what is being executed, where.
    This rule works. I was foolish in testing it via the BPE.
    I start the BPE on my laptop which connects to a UNIX server. Silly me was trying to run a UNIX command on my laptop. oops.
    Opening an xwindows session and starting the BPE on UNIX gives the expected results. Not sure when the BPE is finally killed off (we are on IDM 7.1) how does NetBeans handle this situation.
    GF

  • Execute shell command from within pascal code

    Hello there,
    I am trying to execute a shell command from within my pascal code. I use XCode together with FreePascal. I have tried something like:
    exec ('program', 'options');
    adding the 'Dos' unit to the Uses clause of my program.
    Thus, e.g.,
    exec ('mkdir', '/A')
    to create a directory with the name 'A'.
    However, my attempts so far were unsuccessful. Can anyone help me on this, and perhaps provide a simple example of how to do it right?
    Thank you in advance,
    Shane

    In the mean time, I found the problem myself. I am just posting the solution here for anyone that is interested. My original solution was correct, in that the 'Dos' Unit must be added, and that the right command is 'exec'. There was however a problem with the correct path to the program that I wanted to invoke. In the shell, this program was accessible from anywhere. However, in the 'exec' command, the full path to the program must be given. Since I am not a Unix expert, I don't know the reason for this.
    So, in summary, the solution is:
    Uses Dos;
    begin
    exec ('full path to program', 'program options');
    e.g.: exec ('/bin/sh', '/run.sh') to process the commands in the file /run.sh
    end
    Hope this may be of help to anyone else.
    Shane
    Mac OS X (10.3.9)
    Mac OS X (10.3.9)
    Mac OS X (10.3.9)

  • How to run system commands from JAVA

    Hi Friends,
    How to run windows system commands from JAVA
    Runtime r=Runtime.getRuntime();
    r.exec("dir");
    Throwing following Exception
    CreateProcess :dir error=2
    Thanks in advance
    Hamsa

    Hi ,
    in Windows NT this is not possible, you can use the following :
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    java.lang.Process proc = r.exec("cmd /c dir");
    InputStream is = proc.getInputStream();
    int ch ;
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );

  • 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.

  • Running unix commands from within a procedure

    Oracle 11.1, AIX 6.1
    ================
    A developer would like to know what the commands are to execute from within a procedure to run unix commands on the database server and capture those results back to the procedure for parsing & manipulation.
    Thanks.

    Don't take this as the correct way to do it, but this is merely 'a' way to do it:
    have a db procedure thats executes a db function
    create or replace procedure csproc(p_cmd in varchar2)
    as
    x number;
    begin
    x:=csfunc(p_cmd);
    dbms_output.put_line('x is: '||x);
    end;
    /The function calls a piece of java to execute the os command and return the return code of the os command
    create or replace function csfunc( p_cmd  in varchar2) return number
    as language java
    name 'csclass.RunThis(java.lang.String[]) return integer';
    /Here is the java class to run the os command
    create or replace and compile java source
    named "csclass"
    as
    import java.io.*;
    import java.lang.*;
    public class csclass extends Object
    public static int RunThis(String[] args)
       Runtime rt = Runtime.getRuntime();
        int        rc = -1;
        try
           Process p = rt.exec(args[0]);
          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;
    /and finally the os command - in this case its a very simple shell script
    #!/usr/bin/ksh
    echo "Hi" >> /app/oracle/workdir/cs.logwill have to grant privileges to my user 'CS' to run the various os commands
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.ksh','read,execute');
    exec dbms_java.grant_permission('CS','java.io.FilePermission','/app/oracle/workdir/cs.log','write');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','readFileDescriptor');
    exec dbms_java.grant_permission('CS','SYS:java.lang.RuntimePermission','*','writeFileDescriptor');and finally can run the procedure from within the db
    set serveroutput on
    exec dbms_java.set_output(1000000);
    exec csproc('/app/oracle/workdir/cs.ksh');
    x is: 0
    PL/SQL procedure successfully completed.to prove it works ok the logfile shows an entry:
    'Hi'

  • Executing an OS command from web PL/SQL

    Hi,
    I'm developing a web application with the PL/SQL web toolkit. A link on one of the screens needs to be able to start a batch file on the server (Win2000). Two questions:
    - How an executable or batch file on the operating system be started from a PL/SQL procedure?
    - Once the file is running, I want the browser to go to a new window immediately with the process running in the background. The process could take up to 30 minutes so I don't want the web browser to hang there and time out. Is there some functionality in the PL/SQL web tool kit to allow the next screen to be displayed before the process has finished? (such as the 'Unzip in background' functionality in Portal, for those that have used it).
    Thanks,
    Michael
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Michael Conrick,
    Igatech Consulting.

    (1) You can write a PL/SQL proceudre that wraps a Java Runtime object. That will allow you to execute OS routines. But you have to have Java enabled in the database. That is a big topic but it's covered in several places. The AskTom web site is probably the best place to look, as it gives a good working example. I'm afraid I don't have the exact URL but it has a v.good search engine.
    (2) don't know.
    APC

  • How to execute system command from java program

    Hi all,
    I want to change directory path and then execute bash and other unix commands from a java program. When I execute them separately, it's working. Even in different try-catch block it's working but when I try to incorporate both of them in same try-catch block, I am not able to execute the commands. The change directory command works but it won't show me the effects of the bash and other commands.
    Suggestions??

    The code I am using is....
    try
    String str="cd D:\\Test";
    Process p=Runtime.getRuntime().exec("cmd /c cd
    "+str);your str string is already having cd in it but again you ar giving cd as part of this command also please check this,i will suggest you to remove cd from str
    Process p1=Runtime.getRuntime().exec("cmd /c mkdir
    "+str+"\\test_folder");you should say mkdir once you change your path,but here you are saying mkdir first and then cd D:\Test(this is because of str)..please check this
    Process p2=Runtime.getRuntime().exec("cmd /c bash");
    Process p3=Runtime.getRuntime().exec("cmd /c echo
    himanshu>name.txt");
    catch(IOException e)
    System.err.println("Error on exec() method");
    e.printStackTrace();
    Message was edited by:
    ragas

  • How can I pass system commands from a java program? Urgent!

    hi,
    I have been trying this out since a long time. How do I send system commands to command.com or cmd.exe from a java program and an output of the executed command back to the java application.
    If u have any idea, or have any information about the kind os application reply back.
    Thanks
    Deepa Datar

    This is the code which I tried, but it displays only the title of MS-DOS, something like " Microsoft Corp...etc ". But doesn't take any input, and the subprocess(cmd.exe) hangs.
    import java.io.*;
    public class cmddemo2
    public static void main(String arg[])
    try
    System.out.println("cmd");
    Process p=Runtime.getRuntime().exec("cmd.exe");
    DataInputStream din=new DataInputStream(p.getInputStream());
    DataOutputStream dout=new DataOutputStream(p.getOutputStream());
    System.out.println("after streams");
    String s;
    dout.writeChars("type cmddemo2.java");
    while((s=din.readLine())!="\n")
    System.out.println(s);
    dout.writeChars("dir");
    String s1;
    while((s1=din.readLine())!="\n")
    System.out.println(s1);
    System.out.println("over");
    catch(Exception e)
    { System.out.println("Exception : "+e);

Maybe you are looking for