Unix Scripts and PL/SQL

I want to run a UNIX script via PL/SQL. I want the script to be run with no assistance from an outside source. The script contains a 'ls'. Is this possible and if so, how.

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Christopher Racicot ([email protected]):
You can use an "external procedure", written in C, which then uses the C runtime library to access the UNIX shell. This features is
also known as "callouts".
We will likely add better native support
in PL/SQL for various operating system
activities in a future release.<HR></BLOCKQUOTE>
Can you invoke Perl from within PLSQL?

Similar Messages

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

  • Unix script in PL/SQL

    I am building a txt file using UTL_FILE in PL/SQL and need to email it using a Unix script. How can I add the Unix script to the end of the PL/SQL?

    Well, on the UNIX side of things I have simply used mail -s <subject> <email_address> < <text or file> to send mail inside of a UNIX script and it works fine.
    or you can use cat <some text> | mail -s <subject> <email_address>
    UTL_SMTP works well if you want to have less moving parts and have one script compiled inside the database. I guess if you already have the UTL_FILE working, it would be less work to just add in the code to mail from the UNIX script.
    HTH
    ReedK

  • How ro run unix script freom pl/sql - dbms_scheduler 11.2.0.3

    Hi,
    Using 11.2.0.3 and have a unix script which works fine.
    Want to run this unix script every time a piece of pl/sql runs
    have put below in but doesn't actually run it.
    How can we achieve this?
    Many Thanks
    idea is that file we create locqally on server is copied to another via the unix script caled form pl/sql
    DBMS_SCHEDULER.create_program (
       program_name => 'test_executable_prog',
       program_type => 'EXECUTABLE',
       program_action => '/oracle/jm/data/dataout/copy_tcfile',
       number_of_arguments => 0,
       enabled => TRUE,
       comments => 'CREATE_PROGRAM test using a schell script.');Tried below but no joy
    -- Shell Script (OS executable file).
    /*DBMS_SCHEDULER.drop_program(program_name => 'por_copy_files');
    DBMS_SCHEDULER.create_program (
       program_name => 'por_copy_files',
       program_type => 'EXECUTABLE',
       program_action => ' /oracle/jm/data/dataout/copy_tcfile',
       number_of_arguments => 0,
       enabled => TRUE,
       comments => 'CREATE_PROGRAM test using a schell script.');
    DBMS_SCHEDULER.create_job (
        job_name        => 'por_copy_files_job',
        program_name    => 'por_copy_files',
        start_date      => null,--SYSTIMESTAMP,
        repeat_interval => null,--'freq=hourly; byminute=0',
        end_date        => NULL,
        enabled         => TRUE,
        comments        => 'Job defined by existing program and inline schedule.');Edited by: user5716448 on 03-Oct-2012 08:35
    Getting message when look in all_scheduler_job_run_details
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    even thoug hfile exists
    Edited by: user5716448 on 03-Oct-2012 08:50

    When run for unix command line which o.k
    get
    AUTHSTATE=files
    A__z=! LOGNAME
    COLUMNS=132
    EDITOR=vi
    ENV=/home/oracle/.kshrc
    HOME=/home/oracle
    LANG=en_US
    LC__FASTMSG=true
    LOCPATH=/usr/lib/nls/loc
    LOGIN=oracle
    LOGNAME=oracle
    MAIL=/usr/spool/mail/oracle
    MAILMSG=[YOU HAVE NEW MAIL]
    MAIL_HOST=prdikw01
    NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
    ODMDIR=/etc/objrepos
    ORACLE_BASE=/oracle/app/oracle
    ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
    ORACLE_SID=IKW
    ORACLE_TERM=vt100
    ORATAB_PATH=/etc
    PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin:/usr/local/bin:/etc:/usr/sbin:/usr/ucb:/h
    ome/oracle/bin:/usr/bin/X11:/sbin:/oracle/app/oracle/product/11.2.0/dbhome_1/bin:/oracle/app/oracle/product/11.2.0/dbhome_1/OPatch
    PS1=[$ORACLE_SID]$PWD $
    PWD=/oracle/jm/data
    SHELL=/usr/bin/ksh
    TERM=xterm
    TMPDIR=/tmp
    TZ=GMT0BST,M3.5.0,M10.5.0
    USER=oracle
    _=/usr/bin/env
    dba=/home/oracle/dbaWhen run from pl/sql
    get
    ORA-27369: job of type EXECUTABLE failed with exit code: 255
    STANDARD_ERROR="execve: Exec format error"when try
    dbms_scheduler.create_job(
    job_name => 'POR_JOB',
    job_type => 'EXECUTABLE',
    job_action => '/oracle/jm/data/copy_tcfile',
    start_date => SYSTIMESTAMP,
    number_of_arguments=>0,
    enabled => true,
    auto_Drop => true,
    comments => 'Demo');Above code in pl/sql where create job and schedule job separately gives file not found message even though give full path

  • Unix script and sqlplus statements

    I have a unix file which contains sql statements. Included is the sqlplus statement to log on to the database with the username and password: xxxxx/xxxxxx@sid<<EOF
    When I run the unix file from my command line outside of sql, it runs successfully. When I attempt to run the same file in a cron job, I receive the message, sqlplus: not found.
    How can I run this unix file in a cron job? Is something else needed?
    Thank you,
    GD

    When I log to unix with the root password and issue:
    01 9 23 4 3 su - xx -c ". /home/xx/.profile;/home/xx/test.sh"
    The test.sh script executes successfully.
    When I log on with my userid and put the line in a crontab, I receive the following:
    Your "cron" job on yyy1
    su - xx -c ". /home/xx/.profile;/home/xx/test.sh"
    produced the following output:
    su: Sorry
    If cron is run by ROOT, shouldn't I get the same results?
    GD

  • How to submit a batch compare job using a unix script and cron?

    I understand I can setup a unix script to be used to schedule a database compare job. I'm not sure how to get past the popup log in window tho... When I use the command line and include the -id<myid> the OMS login window pops up requesting login password and service. This won't do if I do not want to run this interactive. I cannot find any syntax for the command line other than --id<adminid>  How to I include the password and service?
    Thanks ;)
    Laurie

    I had the same problem.
    My shell looks like (baseline_ELITE.sh):
    ocm login -idsysman
    ocm capture -l BL_ELITE -idsysman
    I don't have the ocm logout.
    First, run the baseline_ELITE.sh, it will ask you about the password. The next times, it never ask again for the password, but take in account don't use the ocm logout.
    Humberto Gomez
    OCP Dev2k, 8i, 9i
    [email protected]

  • More on unix script from pl/sql

    Hi All,
    There was this discussion on starting unix scripts from within a pl/sql stored procedure started on August 31.
    All comments were targeted towards an oracle 8X solution.
    Does anyone have a solution for 7.3.4?
    Somebody mentioned something about using dbms_pipe package.
    So, just to rephrase the problem:
    - Need to execute any unix command/script from within a pl/sql block (stored procedure). Instance is oracle 7.3.4
    Thanks!
    Enrique

    Hi Juan,
    You can try this solution:
    enable in the the init file the parameter
    utl_file_dir="target_directory"In this way You permit the the DB to writing directly to the filesistem in the directory You specified.
    After restarting the istance You may write Your own code that, using the supplied package UTL_FILE, writes a file in that directory (es. my_script.sh)
    Then, instruct the cron daemon to execute every 1 minute this command.
    You may append to the script the self-destruction after the execution.
    I hope that this will help You.
    Max

  • How to invoke from UNIX script and pass back return code?

    Though I am an experienced developer, I am new to java. I created a class containing a single method. I have performed my testing by running the class class.method from the command line in a UNIX (Solaris) environment. Now, I would like to have the class.method invoked from a UNIX shell script, and to return a success/failure indicator from the method, to the UNIX script. I modified the method to make it return char, rather than being defined as void. Within the class and method, I declared and initialized a char variable. I added a finally clause which contains a single return statement, returning the char return code variable. Within my UNIX script, I invoke the class/method as follows:
    return_code = java myClass
    This does not seem to be invoking the method however. Can someone please tell me what I am doing wrong? Or is more information needed in order for someone to help me out.
    Please let me know.
    Thanks.
    Brad

    stdunbar,
    Using your suggestion of System.exit(retVal); seems to allow the java method to be performed successfully (Thank You). But I am still having a problem with the value being recognized by the shell script.
    In my script, I'm doing the following:
    java MyClass inputparameter > return_code
    export return_code
    echo $return_code
    But return_code does not seem to contain a value. Just before the System.exit(retVal); I added System.out.println("return code = " + retVal ); and I can see that retVal. When I run the java method outside of the UNIX shell script, I can see that retVal does indeed contain a value. So I think my problem might actually be the code in the UNIX script.
    Thanks again.
    Brad

  • Unix Script and Jar files

    I am in the process of designing a new system and wonder if the following is possible.
    I want a UNIX script to execute a Jar file with a status of 1 or 0 (based of success/failure) being passed back from the Jar to the UNIX script.
    I know a Jar file can be executed from a UNIX script but not sure about the passing of a message.
    Would public static void main(String[] args) make it impossible to pass a message or is there some way around this ?
    If a message can be passed back to the Script how would it pick it up ? - `echo $?` ?
    Message was edited by:
    palmeal

    Right, in the shell script you have in $? the return
    code of the last command.
    java ...
    if test $? -eq 0
    then
    echo java was ok
    e
    echo java oops
    If a message can be passed back to the Script howwo
    However the return code is no message.I really don't understand! Are you saying you just want to read something in the shell script that is generated by the Java program but the Java program must keep running and not terminate? If so then use stdout or stderr (as BIJ001 says).

  • Oracle scripts and BO SQL

    Hi,
    It has been a huge benefit to discover that with MS SQL Server we can use not just single SELECT statement in BO but pretty extensive scripts, including creating variables, using multiple intermediate queries, etc. For example, attached is one pretty complex script which runs in BO report (single query).
    However, any attempt to use variables or multiple statements with Oracle DB failed so far.
    Is there is a possibility to do scripts in BO when working with Oracle
    In particular, we would be looking for:
    Declaring variables
    Assigning  values to variables, potentially a value which is a result of a query
    Using variables as part of a query (like defining time frame, sample in SQL Server: “WHERE t.CreationTime >= @StartTime AND t.CreationTime  < @EndTime”)
    Any flexibility here would be of huge help to report developers.
    We are using BI4.0 SP5
    Query which is working with SQL Server.
    DECLARE
      @RTY float = 1.0,
      @TimeNow datetime,
      @StartTime datetime,
      @EndTime datetime,
      @ColorBinNumUnits int,
      -- FATP_RTY variables
        @Build varchar(100),
        @Run varchar(100),
        @PreBurn_RTY float,
        @WIFI_RTY  float,
        @RunIN_RTY  float,
        @PostBurn_RTY  float,
        @FQC_RTY  float,
        @Flash_RTY  float
    --FATP Build / Run
    set @Build = '%'
    set @Run = '%'
    -- Time period ends yesterday 6PM Central time and covers previous 24 hours.
    set @TimeNow = CURRENT_TIMESTAMP
    set @EndTime = DATEADD(HOUR, -6, CONVERT(datetime, CONVERT(date, @TimeNow)))
    set @StartTime = DATEADD(DAY, -1, @EndTime)
    -- CALCULATE RTY
    SELECT
      @RTY = @RTY * (CASE WHEN (NumFail+NumPass) > 0 THEN NumPass * 1.0 / (NumFail+NumPass) ELSE 1 END)
    FROM
    SELECT
      Stage,
      SUM(1-TestResult) as NumFail,
      SUM(TestResult) as NumPass
    FROM
      SELECT
      st.Description as Stage,
      (CASE WHEN LEFT(dbo.ufnEnclosureUnitTestResult(t.ID),4)='PASS' THEN 1 ELSE 0 END) as TestResult
      FROM
      ffTest t (NOLOCK)
      INNER JOIN ffStation s (NOLOCK) ON (s.ID = t.StationID)
      INNER JOIN ffStationType st (NOLOCK) ON (s.StationTypeID = st.ID)
      INNER JOIN ffUnit u (NOLOCK) ON (u.ID = t.UnitID)
      INNER JOIN ffPart p (NOLOCK) ON (p.ID = u.PartID)
      INNER JOIN ffSerialNumber sn (NOLOCK) ON (sn.UnitID = u.ID)
      WHERE
      sn.SerialNumberTypeID = 0 and
      dbo.fn_UspIsLatestTest(t.unitid,t.id,t.testtypeid) = 1 and
      LEFT(p.PartNumber,12) in (SELECT MapKey FROM udtOemExtractsSupportData WHERE MapName = 'ENCL_Parts' AND MapValueStr = 'Housing')
      AND t.CreationTime >= @StartTime
      AND t.CreationTime  < @EndTime
      AND sn.Value Not in ( 'F5K3467004WFL6F18', 'F5K3466004UFL6F1B', 'F5K3473006CFL6F1M')
      AND sn.Value Not like '%Gold%'
      AND st.Description IN (
      'Housing Cosmetic Inspection Post Buff ID',
      'HousingCosmeticInspectionPostBuff OD',
      'Housing Cosmetic Inspection Pre Anodize 1',
      'Housing Cosmetic Inspection Post Anodize 1',
      'Housing Cosmetic Inspection Post Anodize 2'
      ) Q
    GROUP BY Stage
    ) G

    Patricia Blais (guest) wrote:
    : I have bought the book "The complete reference SQL" which came
    : with a trial software CD of Oracle 8. I want to know if it is
    : possible to create a program in PL/SQL (create a procedure) in
    : SQLPLUS v.8 which is also included with the book. If it is
    : possible, I would like to know how, by a small example. I have
    : tried some of the exercices in the volume and they do not
    work.
    : No error messages are given and the program had to be
    : interrupted. Please answer in another way then repeating an
    : example in the book.
    : Thanks in advance.
    ok some code example:
    Let's gues you want to display 2 collums of the view all_tables
    in html format:
    First create a procedure with a editor (i use to do so).
    create or replace procedure get_html (owner_in in varchar2) as
    var1 number(12,0);
    var2 varchar2(100);
    begin
    dbms_output.putline('<table>');
    for fr_rec in (
    select table_name, owner
    from all_tables
    where owner like '%'

  • 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

  • SAP XI: How To Write Shell Script And use it in File Adapter On XI Server

    Hi,
    I want to split file at sender side in XI using Shell Script and then after i want to do
    Mapping.
    Can anyone tell me what exactly it means "write a script in UNIX shell on XI SERVER"?
    Regards,
    Akshay.

    Hi,
    You can execute a Unix script running in the XI server from the File communication channel. Ie. if you want to do something which was not part of XI adapter configuation , then you can make use of external unix script and you can execute those from the XI.
    For this, write a unix script and place in the XI OS level provided that path is accessible from PI Channel.
    E.g
    So u can use this in either Sender Channel to modify the data before it reaches into the Integration Server or in Receiver channel it is generally used to transfer the files into different location via Secure FTP
    SAP help: http://help.sap.com/saphelp_nw2004s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Blog:/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
    XI  can be in any OS.
    Hope this helps,
    Rgds,
    Moorthy

  • Scripts and searching

    The find object capability is useful but I do not see an intrinsic means to search code contained in "Before Create", "After Create" and "End of script" scripts? Not that I'm bashful about grepping the XML.
    I have been placing breadcrumb comments in my scripts so I can see their provenance in the exported DDL -- a preference enhancement perhaps? (Particularly useful for code review where it would be easy to overlook code attached to objects in SDDM and that would otherwise be needles in a haystack amongst the exported DDL)
    So what have I been putting into scripts? Not much since heavy lifting scripts and PL/SQL are best left outside of SQL Developer Data Modeler. My scripting with SDDM has been for materialized view logs since I don't see the means to create them directly in SDDM.

    Hi Kevin,
    thanks for sharing your thoughts. There will be much more advanced find/search facilities in next version of Data Modeler and scripts also will be covered.
    Philip

  • Changing the filenames using unix script

    Hi,
    I have a scenario where I have to change the file names on the Receiver CC using a unix script and add date and timestamp to the file name
    this is what I'll be writing to filename_01.xml I need to change that to newfilename_01_MMDDYYYY_HHMISS.xml
    the 01 in the file name is the counter, so I might having more than one file where 01,02, etc will represent the counter on the filename.
    Any help is really appreciated.
    Thanks,
    Joe.P

    you can try this
    create the field called filename in target
    use a costant and concat it with the out out of UDF( or some functon avaleiable counter) which will genereate numbers like 1,2,3,4,5,6 and send this filename_01 to the output field and use this in the variable substution to genreate the filename by the CC
    if you dnt want to send this fieldin output file then specify that fieldname in CC length as 0

  • Unix Script in Process Flow

    Hi
    I have created Process flow which calls Unix Script and deployed the Process flow successfully. But it is giving error when i execute the process flow saying required scripts are not deployed.
    Do we need to deploy the unix scripts? if yes, could some one advise how do we do this, as i couldn't see modules to import the Unix Script.
    I am using OWB 11G R2.
    Thanks

    Hi
    I have created Process flow which calls Unix Script and deployed the Process flow successfully. But it is giving error when i execute the process flow saying required scripts are not deployed.
    Do we need to deploy the unix scripts? if yes, could some one advise how do we do this, as i couldn't see modules to import the Unix Script.
    I am using OWB 11G R2.
    Thanks

Maybe you are looking for

  • New itunes fixed nothing for me!

    errors 440-448-236-240 all related to: "An existing connection was forcibly closed by the remote host" i just have to run itunes with bonjour service off... no need for it but this worked fine until last update never ever had an issue for years until

  • How do I use creative cloud with an iPad

    I am relatively new to Creative cloud. It is touted as a way to access and work on creative files from anywhere but it does not seem like I can work on those files from my iPad unless I pay extra for touch apps. If that is so then I really cannot wor

  • How do I get A newly installed Scanner to show up in " IMPORT "

    How do I get a newly installed Cannonscan8800F Scanner to show up in " IMPORT "

  • Rogue cpu hog while running WebLogic

    Hello, My application is a servlet/EJB/Oracle application running on WebLogic. During stress test, I am seeing a java thread that is taking up 50% of available cpu on a dual cpu machine. The thread remains at 100% even after the load is over. Here ar

  • OCI Drivers in JDBC receiver

    Hi All, Brief Scenario: Insert data to CLOB field (source field may be more than 4000kb). Requirement to use OCI drivers in JDBC receiver adapter. When calling Stored Procedure to insert CLOB data field, exception thrown by AE or Oracle server: Messa