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

Similar Messages

  • 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

  • Command for exceuting the sql script to a db from linux home

    Hi All,
    Can someone please tell me how to execute the /addev/ad/11.5/sql/adcdexcp.sql against case122 from my linux home for our product.
    Thanks in Advance

    Do not fully understand your question.. but some basics:
    You need an Oracle OCI client driver and Oracle client on the client side. E.g. Oracle Instant Client and Oracle's SQL*Plus.
    You need to connect to the database server (using SQL*Plus as the example):
    sqlplus scott/tiger@db-alias
    Where db-alias is a TNS alias for the database.
    Once connected, you can use SQL*Plus to load the contents of a SQL script, and send a single SQL command (or PL/SQL anonymous block) at a time to the Oracle server for execution. E.g.
    SQL> @/addev/ad/11.5/sql/adcdexcp.sql
    I suggest you point your browser to http://tahiti.oracle.com (Oracle Documentation Portal), and look for the SQ*Plus User Guide for the Oracle version you're running.
    If you can be more specific and provide proper details as to what you are attempting to achieve, forum members will be a better position to provide assistance and advice.

  • Combining UNIX commands into one task

    Up until now I haven't played around with ARD much in terms of managing client settings, but recently I've been asked to change the energy saver settings on around 50 machines. I've collected the relevant terminal commands, and they all work individually. But I wanted to combine them all into one task. Can anyone tell me how this can be done? The only way I can think of would be to schedule the separate tasks in a queue.
    Here's the series of commands I have ended up with:
    defaults -currentHost write com.apple.screensaver idleTime 1
    defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.$(ifconfig en0 | awk '/ether/{gsub(/:/,"");print $2}') askForPassword -int 1
    defaults -currentHost write com.apple.screensaver idleTime 0
    # Set amount of idle time in minutes until a computer sleeps. Specify "Never" or "Off" for computers that should never sleep.
    systemsetup -setsleep 45
    # Set the amount of idle time in minutes until the hard disk sleeps.
    systemsetup -setharddisksleep 90
    # Set the amount of idle time in minutes until the display sleeps.
    systemsetup -setdisplaysleep 15
    Thanks

    I realise this may seem obvious to the more experienced users here, but simply putting colons in between the commands didn't work. I realised that some of these commands needed to be run as root, and some as the current user, so I had to split them into two tasks. Does anyone know how I can get around this? Sudo can't be used without user interaction, so is there another way of running the commands as root within the script?
    Here's what I have now:
    defaults write ~/Library/Preferences/ByHost/com.apple.screensaver.$(ifconfig en0 | awk '/ether/{gsub(/:/,"");print $2}') askForPassword -int 1; defaults -currentHost write com.apple.screensaver idleTime 0; systemsetup -setsleep 45 -setharddisksleep 45 -setdisplaysleep 15; pmset -a halfdim 1

  • 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

  • Using variables in sql scripts

    I am trying to pass a variable into a simple
    sql script - but each time I run it, it still asks for the variable.
    Here is my example:
    test.sql contains:
    select count(*) from &tbl
    I try to run it by typing the following
    at the sqlplus prompt:
    @test the_tbl
    Even though I provide a value for &tbl,
    sqlplus still asks me for the value:
    Enter value for tbl:
    I am sure that the answer is very simple.
    what am I doing wrong ?
    Thanks !

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by KR:
    I am trying to pass a variable into a simple
    sql script - but each time I run it, it still asks for the variable.
    Here is my example:
    test.sql contains:
    select count(*) from &tbl
    I try to run it by typing the following
    at the sqlplus prompt:
    @test the_tbl
    Even though I provide a value for &tbl,
    sqlplus still asks me for the value:
    Enter value for tbl:
    I am sure that the answer is very simple.
    what am I doing wrong ?
    Thanks !<HR></BLOCKQUOTE>
    In SQL Plus 8.0 this command goes correctly:
    select count(*) from &tb ;
    null

  • Unix Command to Wake Up a Mac

    Hi everyone,
    Is there a Unix command to wake up a Mac when its sleeping?
    I want to schedule some updates to run at night or during the weekend but I cant find the command to send to a group of machines if they are sleeping.
    Thanks for your help

    I don't know of any built-in UNIX commands, but there are some scripts that perhaps you could find a way to trigger. Look here for some discussion on the issue.
    Hope this helps.
    Message was edited by: Dave Sawyer

  • Definitions in SQL scripts

    Hi All,
    I have three definitions in my main SQL script
    define user=&1
    define owner=&2
    define grant=&3
    I try to pass these definitions into other scripts that are defined in this main script . This is how I do it
    @create mytestsnapshot.sql &user &owner &grant
    and I'm not getting these definitions to go into the mytestsnapshot.sql script.
    Can anyone advice me how to do this
    Thanks

    How are you accessing them in your mytestsnapshot.sql ?

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

  • Spool Russian Characters from a unix(AIX) sql script

    Hi All,
    I have a problem selecting and spooling a column whose characters are in russian to a flat file. If I use oracle sql developer, the data comes out right, e.g
    Р-Н ТАШКЕНТ
    However is i try to run the same select from a unix sql script and spool the results, I get some gibberish like:
    ò-î ôáûëåîô or a chain of question marks ?????????
    select * from nls_database_parameters gives:
    NLS_LANGUAGE=AMERICAN
    NLS_TERRITORY=AMERICA
    NLS_CHARACTERSET=UTF8
    NLS_NCHAR_CHARACTERSET=AL16UTF16
    I have tried exporting the environment variable using these various options individially to no avail:
    export NLS_LANG=RUSSIAN_CIS.CL8MSWIN1251
    RUSSIAN_RUSSIA.RU8PC866
    RUSSIAN_RUSSIA.CL8KOI8R
    RUSSIAN_RUSSIA.CL8MACCYRILLICS
    RUSSIAN_RUSSIA.RU8PC855
    RUSSIAN_RUSSIA.RU8BESTA
    RUSSIAN_RUSSIA.CL8ISO8859P5
    Please help.
    Thanks,
    Edited by: HouseofHunger on Apr 12, 2012 4:02 PM

    Os version: AIX 6.1.0.0
    Database version: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    with the default values for NLS_LANG, I run sqlplus
    sqlplus user/password@oracle_sid
    select column_name from table_name;
    and the output is:
    column_name
    I exit and export NLS_LANG=RUSSIAN_CIS.CL8ISO8859P5
    go back into sqlplus and run the same query as above, and the output is
    column_name
    À-½ °Ⱥµ½Â
    À-¾½ ÃÀ°ǸÀǸºÁº¸¹
    °Ⱥµ½Â
    °Ⱥµ½Â
    ¾»Â¸½¾¹ À-¾½
    ³ ±µº°±°´
    ΠǸÀǸºÁº¸¹ À-½ ÷±µº¸ÁÂ
    Ä°À³¾½°
    Ϻº°Á°À°¹Áº¸¹
    °Ⱥµ½Â
    Á°¼°Àº°½´
    So it seems the output I get is somehow influenced by the value of environment variable NLS_LANG, so it may be that either I need the correct value for this environment variable or I need some config on the OS level.....?
    Also the command locale -a gives following output - I am not very good on locales, so it maybe that the russian local isn't installed...?
    $ locale -a
    C
    POSIX
    en_US.8859-15
    en_US.ISO8859-1
    en_US
    Thanks

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

  • Sql script in UNIX

    When I run a sql script in unix using sqlplus command, the process halts at some point. No matter how long I wait, it does not finish (it does not bring the command prompt back). There are no problems in SQL*PLUS. This process usually takes about 30 mins when I run from SQL * PLUS. Any ideas why it hangs in UNIX?
    sqlplus -s userid @script
    Thanks

    Are you specifying a password ?
    Have you set the ORACLE_SID ?

  • SQL script into a CASE statement ?

    Hy,
    can someone tell me, please, if is it possible insert into a case statement (shell unix script) one or more SQL script ?
    For example :
    case aaa in
    1 )
    sqlplus blabla <<!
    update ...
    insert ...
    2 )
    esac
    Thank you very much !
    Andys

    /unix/sqlplus -s username/pwd @file_name.sql
    This will work on unix prompt. use this in shell script and implement. file_name.sql containts update logic.
    I hope it will solve ur problem.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Andys:
    Hy,
    can someone tell me, please, if is it possible insert into a case statement (shell unix script) one or more SQL script ?
    For example :
    case aaa in
    1 )
    sqlplus blabla <<!
    update ...
    insert ...
    2 )
    esac
    Thank you very much !
    Andys<HR></BLOCKQUOTE>
    null

  • SQL script with host command job in Enterprise Manger Grid Control

    I use Enterprise Manger Grid Control 10.2.0.5 and need to create SQL script job on database instance target on unix/linux platform.
    I have problem with os command inside sqlplus script.
    For example for the simple command: SQL> host ls
    I get the message in output log: SQL> SQL> SQL> SQL> SQL> SQL> /bin/bash: ls: command not found
    Can anyone help me?
    Thank you.

    Hi,
    Make sure you have granted all necessary rights (log on as a batch job etc.) to the user used in the prefered credentials.
    Cheers,
    Kenneth

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

Maybe you are looking for

  • Can I use a Macbook pro as a second (palette) monitor on my new iMac 21.5" ?

    Hi there, I have a MacBook Pro (13-inch, Late 2011) and the latest 21.5" iMac 2.9GHz. What I would like to do is use the MacBook to load palettes for Adobe InDesign and Photoshop.  I see a lot of discussion about using the iMac to display a smaller s

  • Getting movies onto your ipod

    I can't get my premiere elements movies onto my ipod classic (80Gb) - I can drag the movie into i tunes and watch it using itunes, but when I sync my ipod, it says it cannot synchronise the movie - anyone solved this problem?

  • How to compare date between 2 file?

    hi there... is there any possibility to compare date between 2 file and the file that is latest to open? thank you

  • Accounting document generated even if foreign data incomplete

    Hi, I did the customizing for foreign trade data and I created an incompletion procedure (VI29) for some data like Commodity code, Country of destination, statistic value. I have to create a billing document (export from Italy to France) and my expec

  • Event In iPhone's Photos But Not In iPhoto

    I'm running iOS 6 on an AT&T iPhone 4 and syncing photos through iCloud with my Mid 2009 MacBook Pro running 10.8.2. I noticed recently that there is a random photo event showing up on my iPhone but the same event does not exist in iPhoto 9.4.1 on my