Calling UNIX command from PL/SQL Procedure

Is there a way to call a UNIX command (exa. ls) from within a PL/SQL stored procedure? Looking through the various packages, I didn't see anything that would give me this ability.
I also looked through all the previous questions and nothing looked encouraging.
Thanks in advance,
Russ

Russ,
I thought I'd read a similar question awhile ago and did a search on the word host in this forum and found the following from July 9th that might help you:
http://technet.oracle.com:89/ubb/Forum88/HTML/001611.html
In that post I think the link listed by Barbara Boehmer in has changed to:
]http://asktom.oracle.com/pls/ask/f?p=4950:8:24579::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:16212348050,{host}
It looks like they give solutions for Oracle 7, 8 and 8i.
Good site Barbara, I've added it to my bookmarks.
Hope this helps.

Similar Messages

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • Call Unix Command From Reports Using Java

    Hi,
    Could somebody please show me a sample coding to call Unix command from 10g report using java?
    In metalink doc id 361857.1 does not show much.
    Thanks,
    neemin

    Hi,
    I have a problem with synchronization of the java commands.
    In the Before Parammeter Form trigger, I have:
    function BeforePForm return boolean is
    rt ORA_JAVA.JOBJECT;
    proc ORA_JAVA.JOBJECT;
    v_txt varchar2(32000);
    i integer := 0;
    v_cd_modulo int;
    v_arqlog text_io.file_type;
    cursor c_evento is
    select codigo,
    nome
    from
    (select e.cd_evento || e.cd_edicao codigo
    ,nm_evento nome
    from grh_ev_evento e
    where e.CD_GRUPO in (select cd_grupo
    from grh_ev_adm
    where cd_usuario = (select cd_usuario
    from usuario
    where login_usuario = :AUTHID)))
    order by substr(nome, 11);
    begin
    -- Create the context for logged user
    if instr(upper(nvl(:AUTHID,'RWCLIENT')),'RWCLIENT') > 0 then
    :AUTHID := :SSO_USUARIO;
    end if ;
    TCEENV.SET_TCEENV(:AUTHID);
    if PK_SCA.SCA_GET_USER_RIGHTS(:sca_module_name, :AUTHID) IS NULL then
    srw.message(100, 'Access denided!');
    return (FALSE);
    end if;
    -- Create file in Report Server (UNIX)
    v_txt := '<BR>' || htf.formSelectOpen('P_EV_EDICAO', 'Evento: ');
    :p_file := '/u03/SCAWEB/repout/' || :sca_module_name || '_' ||
    pk_sca.sca_encrypt(:AUTHID || to_char(systimestamp, 'ss.ff'));
    v_arqlog := text_io.fopen (:p_file, 'A');
    text_io.put_line (v_arqlog, v_txt);
    for reg in c_evento loop
    i := i + 1;
    if i = 1 then
    v_txt := '<OPTION SELECTED VALUE="' || reg.codigo || '">' || reg.nome;
    else
    v_txt := '<OPTION VALUE="' || reg.codigo || '">' || reg.nome;
    end if;
    text_io.put_line (v_arqlog, v_txt);
    end loop;
    v_txt := '</SELECT></CENTER></form></BODY> </HTML>';
    text_io.put_line (v_arqlog, v_txt);
    text_io.fclose (v_arqlog);
    SRW.SET_AFTER_FORM_HTML(SRW.FILE_ESCAPE, :p_file);
    rt := RUNTIME.GetRuntime();
    proc := RUNTIME.exec(rt,'rm ' || :p_file);
    return (TRUE);
    end;
    The problem is that there isn't a "synchronize" command, and the
    RUNTIME.exec(rt,'rm ' || :p_file) don't works (it does nothing) because
    the SRW.SET_AFTER_FORM_HTML has a large delay and the following
    command is ignored.
    How can I solve it?
    thanks,
    lmprestes

  • Call unix commands from stored procedures

    My stored procedure requires to call unix commands HOW DO I DO IT?
    null

    i do not know pl sql but in java you can use:
    Runtime.getRuntime().exec("YOUR UNIX COMMAND");
    real example:
    Runtime.getRuntime().exec("ls");
    but you must be careful with using that...
    especially if you want to wait till the process finishes..
    rgds,

  • Sending OS command from PL/SQL procedure

    "How can I send a operating system comand from PL/SQL procedure?
    I want to move , to copy , delete a file from a PL/sql procedure. i.e under unix send mv, cp or
    rm command";
    my e-mail is [email protected]

    take a look at
    http://asktom.oracle.com/pls/ask/f?p=4950:8:881946
    regards
    Freek D'Hooge
    "How can I send a operating system comand from PL/SQL procedure?
    I want to move , to copy , delete a file from a PL/sql procedure. i.e under unix send mv, cp or
    rm command";
    my e-mail is [email protected]

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

  • Unix command from pl/sql

    How can I call a unix command or run a c program
    from a stored procedure in oracle 9i.

    Or if you want to do a host call then implement the following class as a Java stored procedure.
    import oracle.jdbc.*;
    public class util
    // Executes an operating system command. The command shall be fully qualified.
    // The Java connects with silent login. No environment set-up files are run
    // and no path is set. The mode can be "sync" or "async" for respectively
    // synchronous and asynchronous execution
    static public int OSCmd(String cmd, String mode, String[] output)
    throws IOException, InterruptedException
    System.out.println("OSCmd "+cmd+" ("+mode+")");
    output[0]="";
    // start command
    Process proc = Runtime.getRuntime().exec(cmd);
    if (mode.equals("sync"))
    // get command's stdout and stderr
    InputStream stdout = proc.getInputStream();
    InputStream stderr = proc.getErrorStream();
    String str;
    // Stdout
    BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
    while ((str = br.readLine()) != null)
    output[0]+=str+"\n";
    br.close();
    // Stderr
    br = new BufferedReader(new InputStreamReader(stderr));
    while ((str = br.readLine()) != null)
    output[0]+=str+Long postings are being truncated to ~1 kB at this time.

  • Calling Unix command from the plsql

    Hi ,
    I am executing java code from the UNIX Shell script. Before executing this command i want to write plsql code to and pass the files to java command.
    In the plsql code i want to select request id's using the cursor and find the .out files for each request id in the outfile path. once the file is found i want to copy that .out file to the current directory where the java command is going to execute.
    Please suggest me how to use UNIX Command (in my case "cp") to copy the .out file from the outfile path to current directory after opening the cursor.

    If I understand you correctly, you want to generate a log of request id's from the database and send this to the operating system whereby you will execute the following:
    <p>
       <font face="courier">java org.apache.xalan.xslt.Process -XSL combinedfsg.xsl -OUT output.xml</font>
    <p>
    If that is correct, then you should be able to perform all of this w/ PL/SQL by generating the log from the database and write it to the O/S w/ UTIL_FILE. If you want to execute the java code at this point, you should be able to utilize Tom's method with the following:
    <p>
       <font face="courier">exec rc('java org.apache.xalan.xslt.Process -XSL combinedfsg.xsl -OUT output.xml');</font><p>

  • How to call java class from pl/sql procedure ?

    Hello everyone,
    My query is..
    There is one pl/sql stored procedure which is doing some business logic and storing data in some columns of one table, suppose the table name is 'ABC' .. and the rest of columns of table ABC are getting updated using java class. Now my problem is whenever I insert data in ABC using store proc.. i have to call that java class so that it will update the rest columns ( why java class for updating the columns in ABC is ..because that logic cant be done from pl/sql proc.. it has to be done using java )
    and the other thing is.. oracle is in one machine and java is in another .. :(
    hope ..u can help me out !!
    Thank in advance !!

    but that updation have to be done from java code only.. we are using GIS tools .. have to create some shape files and update the column with that shape file.. so creation of shape file has to be done from java code only..
    so how to call java class file which is on another machine and oracle in another..

  • Calling OS commands from PL/SQL

    I want to write a PL/SQL procedure against an Oracle 9i database to import/export data from / to a file into / from a table. I need some advice for this. Please help me out.
    Any advice would be most welcome.
    Cheers
    SrihariKrishna Donepudi

    Not to mention SQL*Loader.
    Cheers, APC

  • Starting Unix Script from pl/sql procedure

    I would like to start any unix shell script out of oracle.
    I don't want use DBMS_PIPES, because then I always need a unix daemon.
    Is there a package wich allows to a call similar to
    "os_result := dbms_systemcalls.call_unix_system
    ('/usr/bin/ls -la');
    null

    What version of Oracle are we talking about here? If it's v8 then I think what you're after is a pl/sql external procedure which I can tell you how to set up.
    Andy
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Christoph:
    I would like to start any unix shell script out of oracle.
    I don't want use DBMS_PIPES, because then I always need a unix daemon.
    Is there a package wich allows to a call similar to
    "os_result := dbms_systemcalls.call_unix_system
    ('/usr/bin/ls -la');<HR></BLOCKQUOTE>
    null

  • Calling UNIX Command from another server using ODIOScommand utility

    Hi,
    My unix script 'runmanger'  is on another server say 'St23456wer' under  /u10/DV2/ofsaa/fic/xxx/bin. I want to call this 'runmanager' using ODIOSCommand. My ODI agent is installed on different server. I can ping 'St23456wer' server from ODI server. How can I call this unix script.

    My only experience with this is connecting to source files on a remote linux server and the two options I was presented with were 1) creating a mount to make the files 'local', or 2) set up a new agent on the remote server.
    One of the gurus may have a better answer for you.

  • Call OS command from PL/SQL

    Hi expert,
    I am using 10gDB on Linux , I have found many website desribe above mention topic. and suggest few method as below : -
    1) DBMS_PIPE
    2) PRO/C
    3) JAVA
    4) DBMS_SCHEDULER
    In fact , My major execute OS command as below : -
    1) copy file to another directory.
    2) remove file in directory.
    3) call some tools to manipulate file.
    4) send email by command line.
    Could u let me know which method is best ? because some command may not
    execute success by each method.
    boris

    I'm not sure what you mean by
    "besides, u have't seen stability issues with either approach. how to do ??? dead la.
    i think every DBA in the world also face this problem ."
    Particularly the sentence
    "how to do ??? dead la."
    I think you are asking how to do something that you refer to as "dead la", but I can't figure out what "dead la" might mean. Is that an abbreviation for something? Or am I misunderstanding what you are trying to say?
    Justin

  • Calling Linux Command From Pl/SQL

    Hi!
    I need to create a trigger which will call a linux command. Basically, when a value changes in a table, I would like to run a linux script. The value in the table can change anytime during any day. I had a look at DBMS_JOB.SUBMIT but I'm not sure if this will work for me because I only need to run the linux script once - when the trigger is fired. I also don't wanna clutter the job queue. Please help. Thanx in advance.

    You didn't mention if you're looking for synchronous or asynchronous execution of your Linux command. Should the program wait for it to complete?
    If it has to be synchronous, you'll need to look into using the external program listener. If asynchronous is ok (and it usually is) and then I'd go with scheduling a job - don't worry about "cluttering up the job queue".
    If you're on 10g or later, don't bother with DBMS_JOB - use DBMS_SCHEDULER instead, which makes it much easier to execute an external process.

  • Call a unix script from pl/sql package

    Hi,
    Using 11.2.0.3 on AIX.
    Is it possible to call unix script from pl/sql package?
    I am cretaing a file in a directory but would like this to automatically be written to an archive directory as well.
    Could either use 2 utl_file.put_lines to 2 separate directories or 1 utl_file and cal script to archive file in another directory.?
    Thoughts?
    Thanks

    user5716448 wrote:
    What am I doing wrong?think how file name will look like:
    SQL> select 'file_name' || to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
    'FILE_NAME'||TO_CHAR(SYSDATE
    file_name15/08/2012 11:47:51Will AIX swallow such name? Obviously not. And, unfortunately, UTL_FILE.FCOPY doesn't raise an error in such case. So use someting like:
    UTL_FILE.FCOPY ('SOURCE_DIR',v_FILE_NAME,'DEST_DIR',v_file_name||to_char(sysdate,'DD_MM_YYYY_HH24_MI_SS'));SY.

Maybe you are looking for

  • Creating a DBI Report with a Generated Data Source

    Hi all, I am on a customer site helping them to implement DBI. We're using DBI Designer to create some Custom Reports. We're interested in using Generated Data Sources in order to simplify handling of the complex Time Hierarchies implemented as stand

  • Illustrator vs InDesign vs Rip software problems

    I have had this type of conflict for some time now. Maybe since CS3. It has occured in 2 ways... But both stemming from InDesign. If you create a drop shadow in InDesign (I'm not sure what method or the exact details) Then export the file, PDF or .AI

  • How to move Apple TV icons

    To anyone that might be interested, I stumbled across a way to reorganize the icons on the Apple TV. I have placed a link to a video I made about it. http://youtu.be/nTxNb8U6K50

  • How to export & email images transferred to lightroom from a disk

    I loaded some old, saved images I have on disk to Lightroom. When I attempt to export the image to email, the command states It can't locate the mage, even though I am looking at it. What am I doing wrong?

  • Table maintenace generator

    hi all, i had created table maintenance generator for my ztable. and now i made some changes to the table  again do i need to maintain . if so how? regards, siri.