Call unix command in sqlplus script

Hello, I wanna to know how to call a unix command in the sqlplus script.
For exemple,
I've a sqlplus script to lauch a oracle report, after the report is generated, I wanne to replace the output file in an other directory.
So that, I have to call the unix command mv here in the sqlplus script
How can I do it?**
I completed my situation:
I don't have dbms_scheduler untility in my database.
Thanks a lot for your help
Edited by: user11930885 on 17 janv. 2010 14:53

Yes, at the begining, I'll tried the unix shell by calling SQL.
I've the problem of passing the parameters through.
It seems to me
we can use
Host in the SQLPLUS to run the unix command.
but I've written it in my sqlplus script, it doesn't work. so I wanna to find an exemple how to use HOST in sqlplus script?
I would have loved to give you an example..but its not unix on my laptop.
But what i can tell you is...u should be doing otherway round.
Not calling Unix commands from SQL but calling SQL's form unix.
You got shell scripts for that.
Write a shell script. Login to SQL execute your code.
exit from sql and then move your file with MV. That's it.
Do post how far you get after trying this.

Similar Messages

  • 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

  • ASAP:stored proc calling Unix commands

    i want an Oracle stored procedure to call unix commands as well as do sqlldr ... opern.
    requirement is :
    the stored procedure needs to do :
    for all files in a Directory:
    do
    { .. use sqlldr to insert data in tbls
    .. move the processed file into another directory
    so,for ls &mv commands i need the Command/way out.
    null

    Hi Jorma,
    It's been a while since I did it, but I successfully did what you
    are trying to do. All I did was "load" the remote interface and
    "stub" class into the database using the "loadjava" utility. My
    environment was Oracle 8.1.7 on SUN (Sparc) Solaris 7.
    Although I haven't tried it, you may be able to invoke a servlet
    from your java stored procedure. The advantage over RMI is that
    you don't need to generate and load a "stub" class. Naturally, you
    would use the "java.net.URLConnection" class to invoke a servlet
    on some web-server/servlet engine which you can communicate with
    using "streams" -- java.io.InputStream and java.io.OutputStream
    Also, I understand that there is now a "oc4jclient.jar" (not 100%
    sure of the name) file that can be "loaded" into the database,
    which allows you to contact EJB's in Oracle's OC4J product. I
    think you can either do this directly, or indirectly using JMS
    over Oracle AQ.
    [JMS = Java Messaging Service]
    [AQ = Advanced Queueing]
    Good Luck,
    Avi.

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

  • Calling unix command in Apex Window

    I am working on a small project where in; it would be handy to run an external plsql in oracle database which calls for unix command such as tail -f alert.log or tail -1000 alert.log when a button is pressed in the application.
    I know the client and server aspect and very difficult to forward the server output to Application specially web based but still thought of trying my luck to get some insights from this forum .
    Is this possible in Apex ?
    UK

    Don't see why not. All the building blocks are there (assuming a recent version of the database, and that 1000 is a realistic metric of the data volume):
    1. A script to run the required UN*X commands.
    2. An initial log extract file created manually using the script.
    3. An external table on the log extract file.
    4. An external scheduler job to rerun the log extract script to refresh the log extract.
    5. An APEX page with a report based on the external table, and a button that calls the external job.
    Note that providing relevant information when asking a question is helpful in determining a solution:
    - APEX version
    - DB version and edition
    - Web server architecture (EPG, OHS or APEX listener)
    - Browser(s) used
    - Theme used
    - Templates used

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

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

  • Calling unix commands

    is it possible to execute UNIX commands from database procedures, say i'm trying to call the logger utility of unix? this procedure is not called from forms it runs at the backend only.
    thanks,
    victor

    Check it out at : http://www.dbasupport.com/forums/showthread.php?threadid=3703
    http://www.dbasupport.com/forums/showthread.php?threadid=2688
    null

  • Running unix commands from sqlplus

    I will like to change my directory from sqlprompt. What is the command to do that?
    SQL>

    Don't think you can do what you want. The 'host' or '!' command in sqlplus spawns another shell, as soon as it returns the settings are back to the parent shell "the one that started sqlplus".

  • 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

  • Shortdump while calling UNIX command

    Hi all,
    I have a problem while trying to remove a file in UNIX platform in ABAP program.
    It is working fine in the development and quality server, but not in production server.
    Based on the debug result, the shortdump was thrown while executing "CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command".
    Below are the message return in the program shortdump
    How to correct the error                                  
        You can check the authorization beforehand with the   
        function module AUTHORITY_CHECK_C_FUNCTION.           
    Short text                                            
        No authorization to call the C function "SYSTEM". 
    DATA: lv_command(100) TYPE C,
            client_path LIKE RCGFILETR-FTAPPL,
            server_path LIKE RCGFILETR-FTAPPL.
      DATA: wa_files  TYPE rsfillst,
            it_files  LIKE TABLE OF wa_files.
      CALL FUNCTION 'SUBST_GET_FILE_LIST'
        EXPORTING
          dirname      = gv_unix
          filenm       = '*'
        TABLES
          file_list    = it_files
        EXCEPTIONS
          access_error = 1
          OTHERS       = 2.
      IF  sy-subrc = 0.
        LOOP AT it_files INTO wa_files WHERE TYPE <> 'directory'.
          CONCATENATE wa_files-dirname wa_files-name INTO server_path.
          CONCATENATE p_fname wa_files-name          INTO client_path.
          CALL FUNCTION 'C13Z_FILE_DOWNLOAD_ASCII'
            EXPORTING
              i_file_front_end    = client_path
              i_file_appl         = server_path
              I_FILE_OVERWRITE    = 'X'
            EXCEPTIONS
              FE_FILE_OPEN_ERROR  = 1
              FE_FILE_EXISTS      = 2
              FE_FILE_WRITE_ERROR = 3
              AP_NO_AUTHORITY     = 4
              AP_FILE_OPEN_ERROR  = 5
              AP_FILE_EMPTY       = 6
            OTHERS                = 7.
          IF sy-subrc = 0.
            concatenate 'rm -f' server_path into lv_command separated by space.
            condense lv_command.
            CALL 'SYSTEM' ID 'COMMAND' FIELD lv_command.
            CLEAR: lv_command.
          ENDIF.
        ENDLOOP.
      ENDIF.
    Anyone knows why and how to resolve this?
    Kindly provide your feedback and input. Thanks in advance.

    You don't have authorisation in PRD to remove files. If it is really required for you.
    Take SU53 screen shot  immediately once you get short dump and follow up with Basis Folks for required authorisation.
    Thanks,
    Raj

  • Calling wlst commands from utility script?

    Hi all,
    I'm trying to write some utility functions to wrap things like create() and delete() with some error handling code. So I would have a module like utils.py and it would contain methods like myDelete(), myCreate(), etc. I would like them to then call WLST's delete() and create(). Then I would have a script that creates and deletes queues, for example, that would use utils.myDelete() etc. However this doesn't work and I can't figure out why.
    If I just reference the wlst commands directly, I get "Name Error: cd."
    If I import
    from weblogic.management.scripting import WLScriptContext as wlst
    WLST = wlst()
    I get "... Unknown error...Use dumpStack()..." But dumpStack()'s output is empty.
    If I extract wlstModule.py from the jar file and try importing it, I get "no module named wlstModule."
    Suggestions?
    thanks

    Hello John,
    Here are the steps you can follow to import wlst into other jython modules.
    Extract wlstModule.py from the jar or you can also use the command writeIniFile(<file-path>) for WLST to write out the module file. Place wlstModule.py in the directory where you are going to invoke jython from or where you have your other utility scripts. In your utility script you should import the module as
    import wlstModule
    And in the script wherever you would like to call any wlst commands you should use wlstModule.<command>. Also use straight jython while invoking the scripts as
    java org.python.util.jython instead of java weblogic.WLST.
    Thanks,
    -satya
    BEA Blog: http://dev2dev.bea.com/blog/sghattu/

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

  • Passing UNIX command in SQL Script

    Hi,
    I am writing a sql-script in unix.
    The logic is as below:
    SELECT flag FROM dummy_table;
    If flag = Y Then
    cp ./abc.txt $HOME/abc.txt
    Else
    SELECT id, roll FROM employees;
    Please help me out.
    Thanks and Regards,
    Tony

    I did that way:
    Under SYS create the following procedure:
    CREATE OR REPLACE PROCEDURE SYS.LINUX_RUN (PATH     IN     VARCHAR2,
                                               result      OUT VARCHAR2)
    IS
       script_file   VARCHAR2 (40) := 'my-temp-script.sh';
       script_data   VARCHAR2 (4000);
       MyFile        UTL_FILE.file_type;
       d             VARCHAR2 (4000);
       dump_file     VARCHAR2 (40) := '/tmp/my-temp-file.dat';
       dump_type     UTL_FILE.file_type;
    BEGIN
       pms.post_calls;
       -- Open file
       MyFile := UTL_FILE.fopen ('TMP', script_file, 'w');
       -- Write data to file
       script_data := PATH || ' > ' || dump_file;
       UTL_FILE.put_line (MyFile, script_data, FALSE);
       -- Close file
       UTL_FILE.fflush (MyFile);
       UTL_FILE.fclose (MyFile);
       -- Purge old logs, no fun anyway
       DBMS_SCHEDULER.purge_log (JOB_NAME => 'TEST');
       -- Execute script
       -- The job is created as disabled as
       -- we execute it manually and will
       -- drop itself once executed.
       DBMS_SCHEDULER.create_job (job_name              => 'TEST',
                                  job_type              => 'EXECUTABLE',
                                  job_action            => '/bin/sh',
                                  number_of_arguments   => 1,
                                  start_date            => SYSTIMESTAMP,
                                  enabled               => FALSE);
       DBMS_SCHEDULER.set_job_argument_value ('TEST', 1, '/tmp/' || script_file);
       DBMS_SCHEDULER.enable ('TEST');
       -- Wait for the job to be executed
       -- usually done within 1 second but
       -- I set it to 2 just in case.
       DBMS_LOCK.sleep (2);
       -- Open the output file and
       -- print the result.
       dump_type := UTL_FILE.fopen ('TMP', dump_file, 'r');
       UTL_FILE.get_line (dump_type, d);
       result := d;
       LOOP
          BEGIN
             UTL_FILE.get_line (dump_type, d);
             DBMS_OUTPUT.put_line (d);
          EXCEPTION
             WHEN OTHERS
             THEN
                EXIT;
          END;
       END LOOP;
       UTL_FILE.fclose (dump_type);
       -- Clean up our temp files
       UTL_FILE.fremove ('TMP', script_file);
       UTL_FILE.fremove ('TMP', dump_file);
    END;
    /And grant execute on this procedure to end user.
    Then under granted user you can use this procedure in your PL/SQL code.
    It works just fine for me :)
    Good luck.

  • How to call a HP-UX command or shell script from Forms 4.5

    Does anybody know how to call a unix command or shell script to get a files list of HP-UX server from Oracle Forms 4.5 on client side? I tried to use DBMS_PIPE package to get it done but I failed. Please let me have the solution if anybody knows how. Very urgent!

    I tried the host command before and it just let me shell to the DOS environment but not HP-UX environment as Forms was running on Windows platform. So, I could not run a unix command or a shell script. Is DBMS_PIPE the only way to get it done?

Maybe you are looking for