Unix command using in pl/sql

Hi all,
Can we use unix command in pl/sql statement..
Regards,
Manikandan.k

Hi Manikandan,
You cantry this via Oracle Database Jobs. You can create a Job that uses your Shell Script & then execute the job in a procedure / function. It's one of the ways to access the underlying Operating System via PL/SQL.
Regards,
Sandeep

Similar Messages

  • Execute unix command using java

    Hello
    Can we execute a unix command using java? If it is how we can execute. Is this affect the performance of the program.
    Thanks

    I tried what you said. But its not working and returning error message,
    java.io.IOException: CreateProcess: ls -a error=2
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    If i try this statement,
    Runtime.getRuntime().exec("c\windows\notepad");
    It is working fine.
    Any idea about this.
    Plz ...........

  • Excute Unix command Using PL SQL

    Greeting,
    how can I execute shell unix commands from PL SQL and without passing by the Java virtual machine, because my database server is not very performant to support the heaviness of Java.
    Thank you for ur help!!!

    Is this what you need ?
    TEST@db102 SQL> create table test(dir varchar2(100), url varchar2(200));
    Table created.
    TEST@db102 SQL> insert into test values('/tmp','http://otn.oracle.com');
    1 row created.
    TEST@db102 SQL> commit;
    Commit complete.
    TEST@db102 SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [ora102 work db102]$ cat /tmp/wget.sh
    #!/bin/bash
    rm -f /tmp/index.html
    /usr/bin/wget -P $1 $2
    [ora102 work db102]$ sqlplus test/test
    SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 29 17:11:28 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    TEST@db102 SQL> DECLARE
      2     v_dir   varchar2(100);
      3     v_url   varchar2(200);
      4  BEGIN
      5     select dir, url into v_dir, v_url
      6     from test;
      7     DBMS_SCHEDULER.CREATE_JOB(
      8     job_name=>'testjob',
      9     job_type=>'EXECUTABLE',
    10     job_action=>'/tmp/wget.sh',
    11     number_of_arguments => 2,
    12     enabled => FALSE);
    13     dbms_scheduler.set_job_argument_value('testjob',1,v_dir);
    14     dbms_scheduler.set_job_argument_value('testjob',2,v_url);
    15     dbms_scheduler.enable('testjob');
    16* end;
    TEST@db102 SQL> /
    PL/SQL procedure successfully completed.
    TEST@db102 SQL>sorry for lost indentations, but tags do not help us these days....

  • Unix command into a pl/sql script

    Could you tell me how to run a unix command (cp, rm, mkdir....)
    into a pl/sql script ?

    sigh this is an old chestnut. it can only be done using a java stored procedure. the instructions for doing this can be found in old postings on this forum - use the Search facility. alternatively try the AskTom site, and Metalink posted a solution as well.
    rgds, APC

  • Running unix command using java shows error

    Hi All,
    I am trying to run UNIX move command using Java exec method but its throwing error, unable to rename. Here below is the code i am trying to run to move all files from one directory to another directory. source and destination directory exists.
    public class Demo
        public static void main(String args[])
            try
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec("mv /home/demo1/* /home/demo2");
                int exitVal = proc.waitFor();
                System.out.println("Process exitValue: " + exitVal);
            } catch (Throwable t)
                t.printStackTrace();
    }if i give "mv /home/demo1 /home/demo2" in exec method, its working, with * character its giving problem.
    Please help me in resolving the problem.
    Thank you

    Characters like *, >, &, |, etc. are interpreted by the command shell--that is by the bash, zsh, etc. programs. When you execute a command with ProcessBuilder or Runtime.exec, you're not going through one of those shells, so their interpretation of those characters is not available.
    In your code, the character * is being delivered directly to the mv command (which doesn't think * is anything special), as opposed to being turned into a list of files and directories as it would be when it's interpreted by the shell. The mv command doesn't know anything about the * character being special.
    If you want to have those shell interpretations, you need to execute the command through a shell. One example is like so, but a) you'll want to read up on the methods in exec() that take arrays of String, and b) you'll want to read up on ProcessBuilder, and c) you'll need to check your shell's man pages to see the exact syntax and arguments.
    runtime.exec("/bin/bash -c 'mv x/* y'");

  • Help with 2 UNIX Commands using ARD

    Hello All,
    Can someone help me with 2 UNIX commands I would like to set up? The first one... how to delete a range of users within /Users by date (i.e. the oldest user who last logged in "Mar 22 09:40 00796216" to "Mar 25 17:01 01036773"). Currently, I'm using "sudo rm -r " followed by each home directory name separated by a space. It works but to save time, it would be nice to do this all within 1 UNIX command.
    Second, is there a UNIX command where I can delete a range of users by ID numbers? (We have users assigned with an 8 digit ID number. Is there a UNIX command where I can delete users from 12345678 to 23456781?) Again, I'm using "sudo rm -r " followed by each home directory name separated by a space.
    Thank you in advance!
    Mike

    This happens with or without SIM card, with and without wifi... with and without SD card as well-- even bought a new 32GB class 10 SanDisk-- but it still crashed.
    Just an update: Went to the Nokia Care Center yesterday, they reflashed the firmware and I got back the phone within the day... when I went back home to try the phone again... again it kept hanging... in a period of 5 minutes, I had 5 hangs... right from startup, went straight to the cam, took some pics then pinched zoom... and phone simply crashed-- had no SD car, no sim card then.
    So today I went back to Nokia Care Center... they said they will do some more tests and see... but they insist its a software problem, we'll see in a day or 2.

  • How to Move file / call UNIX command using ABAP Program

    Hi, ABAP Guru.
    I need to Cut & Paste file (Move file from one location to another location) on Network Shared Drive using ABAP program.
    But I can't figured out how to do this and what ABAP Command / FM / Method (and maybe UNIX command) that being used.
    Please give me the advice.
    Best regard and Thank you all.
    Nattapash C.

    all methods for your requirements should be in class CL_GUI_FRONTEND_SERVICES

  • Operating system Cammand such as UNIX command using PL/SQL

    Hi All,
    I am using forms 4.5 using oracle financials 10.7 and I want to execute an operating system file such as move on server side. I am able to do it on client side using host command but cannot figure out how I can use it on server side. I am using following version of oracle:
    Oracle8i Enterprise Edition Release 8.1.7.3.0 - 64bit Production
    PL/SQL Release 8.1.7.3.0 - Production
    CORE 8.1.7.0.0 Production
    TNS for HPUX: Version 8.1.7.3.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production
    Thanks
    Aqil

    If I dont have java support is there no way to solove this problem?Steven Feuerstein provides some simple example here
    http://apex.oracle.com/pls/otn/f?p=2853:4:12114297745467903505::NO::P4_QA_ID:3202

  • Invoke and Execute Unix command from Oracle PL/SQL

    Dear All,
    I am currently working in the development of multi user application in ORACLE.
    My problem is,
    I have to remove a temporary file created in unix server when a particular condition is satisfied in a PL/SQL proccedure.
    I searched for this and got solution to use DBMS_PIPE package.
    Can you help me how to pack the content 'rm file_name' from different users working in different sessions and how to execute. Can you please explain me how the server manages calls from different sessions and replies to individual sessions.
    Thanks in advance,
    Shenbaga.

    Well if doesn't raise an exception it succeeded. Is that sufficient acknowledgement?
    Cheers, APC

  • SFTP using Unix command

    Hi all,
    I am trying to upload a file from SAP to a folder in another server.
    Here they want us to use SFTP port 22 which is not supported by SAP by default i guess.
    Could any one give me clear procedure and commands to be used in program in order to upload the in file in the server.
    If you could give the methods and FMs and unix commands used it would be great.
    I went through lot of threads but very few are talking about SFTP and i am not the clear about how to go with it.
    Few say that we need to create and external command in SM59.
    IF it is so can you tell what exactly are the parameter to be given for ex i want to put a file so what would be the parameters and how do we use this command in my program
    Any sample code which puts the file another server???
    Thanx

    Check if your able to do sftp at command line from the server where BPEL is running.
    --Prasanna                                                                                                                                                                                                   

  • How to run an applescript using unix command

    Hi All,
    Can any one help me in giving me the command for running an apple script thru postupgrade shell file in other words i wana run an apple script while running my new installer that will upgrade the old version of application but while installing i want to run an applescript so as i know ill have to give that applescript path in the postupgrade script but how to run it while installation and where to keep it (is it postupgrade). May be in short how can i run apple script thru unix command.

    Use the osascript command.
    In my installer, I use the DropDMG program to build my DMG disk image. It doesn't quit automatically, so I have to do the following:
    osascript -e "tell application \"DropDMG\" to quit"
    Type "man osascript" for more information.

  • Invoking Unix command with java stored procedure

    Hi,
    I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
    Thanks in advance,
    Marutha

    Hi,
    Do you get any output while running the code?
    I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
    declare
    x number;
    begin
    dbms_output.enable(1000000);
    dbms_java.set_output(1000000);
    x:=system_command.run_command('testconnect.sh');
    dbms_output.put_line('Returned value='||x);
    exception
    when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
    end;
    <system_command.run_command> - replace with a call to your java stored procedure.

  • Newbie: how to temporary results and handle sessions running UNIX commands?

    Hello,
    I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
    I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
    My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
    UNIX.launch("cd /var/core");
    UNIX.launch("rm obsolete_core_file");
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
    java UNIX "cd /var/core";
    java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
    pwd => current directory
    java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
    pwd => current directoryI would like to have:
    pwd => current directory
    java UNIX "cd /var/core"
    pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
    Thanks again
    Dominique

    scampsd wrote:
    Hello,
    I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
    I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
    My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
    UNIX.launch("cd /var/core");
    UNIX.launch("rm obsolete_core_file");
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
    java UNIX "cd /var/core";
    java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
    pwd => current directory
    java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
    pwd => current directoryI would like to have:
    pwd => current directory
    java UNIX "cd /var/core"
    pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
    Thanks again
    DominiqueWhy not just use plain java File I/O http://docs.oracle.com/javase/tutorial/essential/io/fileio.html and JDBC http://docs.oracle.com/javase/tutorial/jdbc/basics/processingsqlstatements.html for fulfilling your requirements?
    Edited by: maheshguruswamy on Aug 20, 2012 10:32 AM

  • How to run piped Unix commands

    Hi,
    I'm trying to run piped Unix commands using Runtime.getRuntime().exec(...) but apparently the pipe symbol ("|") doesn't seem to work...
    Here is basically what I'm trying to do: running "command1 | command2" where both "command1" and "command2" have dynamic values. I could create a shell script and execute it through Java but there has to be a cleaner way...
    Can anyone help me with this?
    Thanks,
    Thierry

    The | symbol for a pipe is understood by a shell, so it was right to point to this direction.
    If you still have a problem, that might be because of another reason. What did happen, how exactly� did it not work? Did you take care of the stdin and stdout channels of the launched process?

  • ARD: Unix commands wait forever

    Hello,
    I run a cluster of 30 iMacs. We've just updated them to Mountain Lion, and when trying to control them via ARD, all Unix commands (even hostname or echo a) show as "waiting" and never complete.
    All machines involved are running Mountain Lion (or Mountain Lion Server in the case of the ARD master machine) and ARD 3.6.2.
    Can you think of anything that might be causing this? Unix commands used to work instantly before the upgrade to Mountain Lion.
    Thanks,
    Louise

    In addition to the sources Templeton mentioned, a good book on UNIX for Mac OS X (such as the O'Reilly books) would be useful. You can send through ARD many of the UNIX commands that Mac OS X recognizes, though of course you have to be careful what you send or you can cause yourself lots of problems.

Maybe you are looking for

  • Need to import Rules from 10.3.9 to 10.4

    I just made a clone of my existing 10.3.9 OS and all folders to a FireWire external hard disc, which is bootable. In fact, I am using Safari on the old OS in order to submit this post, since I am finding the new OS a bit of a nuisance to set up. So y

  • EJB 3.0 - problem with persistence unit.

    Hi everybody, I got this problem I would like you to help me. I'm doing a proyect with EJB 3.0 using Netbeans 5.5 and Jboss The data source is MySQL. When I deploy the proyect, the Jboss Log show me this: --- MBEANS THAT ARE THE ROOT CAUSE OF THE PRO

  • How to display images at runtime in a web appplication

    i use C#. and also, how do i get an image to be downloaded from mysql database at runtime upon request. here is a bit of my declaration code and conditional construct code  byte [] f = (byte[])(read["Passport"]); // this reads d byte data from the co

  • Search text in Excel table in a Word 2013 document

    Hello, someone would be there if there is a file content search tool on Windows (such as Google search or DocFetcher ..) that would return a string in an Excel table itself contained in a word document 2013. This worked with such DocFetcher with old

  • PS10 Elements does not open in Windows 8, or opens only once. Can it be fixed?

    PS Elements 10 preinstalled on my new computer with Windows 8. It worked fine for a week, now opens once, then won't open again, or doesn't open at all. Adobe gives no support to fix this (they told me to research the answer on their site), yet their