Calling shell script from stored procedure.

Hi Everybody,
Could anyone tell me how to call a shell script from a stored procedure.
Thanks,
Vasu

You would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
Justin

Similar Messages

  • Calling shell script from sql procedure

    Hi gurus
    Is it possible
    1)to call a shell script from sql procedure
    2)that shell script has to return one value
    3)and again sql procedure(calling shell script) has to capture the return value.
    please help me to write this script

    You may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
    Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
    . You will also need to :
    1.     Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
    As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
    Shailender Mehta

  • 11g - calling shell script from trigger

    From what I read so far, starting from 11g onward user credential IS REQUIRED in order to call the shell script from database procedure/trigger.  I am working in a shop where they used SSO (so no password) and having a local user with password is not possible.
    I wonder if anyone used any other method to call the shell scripts from database procedure/trigger?
    Thanks all

    user550338 wrote:
    performance is not going to be a problem for this requirement b/c it ONLY happened after the startup or before the shutdown.
    That still -- even more so --- sounds like a bad idea.  Exactly what does this shell script accomplish that needs to be triggered by database startup/shutdown?

  • Can we call shell script from oracle 9i?

    Hi experts,
    I wanted to know can we call shell script from oracle 9i procedures? If yes,how
    Thanks
    Shaan

    No. I can't think of a way to do this...
    If you want you can use DBMS_SCHEDULER to call OS SHELL scripts within.
    For e.g.
    CREATE PROGRAM
    begin
    dbms_scheduler.create_program
    program_name => 'CHECK_TIME',
    program_type => 'EXECUTABLE',
    program_action => '/opt/oracle/chk_date.sh',
    enabled => TRUE,
    comments => 'Check the Time'
    end;
    CREATE A SHELL SCRIPT
    opt/oracle> cat chk_date.sh
    #!/usr/bin/ksh
    echo "The date is :`date`"
    CREATE SCHEDULE
    begin
    dbms_scheduler.create_schedule
    schedule_name => 'EVERY_30_MINS',
    repeat_interval => 'FREQ=MINUTELY; INTERVAL=30',
    comments => 'Every 30-mins'
    end;
    CREATE JOB
    begin
    dbms_scheduler.create_job
    job_name => 'RUN_CHECK_TIME',
    program_name => 'CHECK_TIME',
    schedule_name => 'EVERY_30_MINS',
    comments => 'Run the program CHECK_TIME every 30 minutes',
    enabled => TRUE
    end;
    MANUALLY RUN A JOB
    exec dbms_scheduler.run_job('RUN_CHECK_TIME');

  • Calling shell script from apex application

    Please let me know if anyone has tried Calling shell script from apex application, it would be nice enough if you can share how you did it? Thanks

    Hi,
    Requirements
    * CREATE JOB (10g Rel.1)
    * CREATE EXTERNAL JOB (10g Rel.2 / 11g)
    * EXECUTE on dbms_scheduler (granted to public by default)
    Since Oracle 10.2.0.2 the commands are executed as user nobody.
    Code:
    --Create a Program for dbms_scheduler
    exec DBMS_SCHEDULER.create_program('RDS2008','EXECUTABLE','c:\ WINDOWS\system32\cmd.exe /c echo 0wned >> c:\rds3.txt',0,TRUE);
    --Create, execute and delete a Job for dbms_scheduler
    exec DBMS_SCHEDULER.create_job(job_name => 'RDS2008JOB',program_name => 'RDS2008',start_date => NULL,repeat_interval => NULL,end_date => NULL,enabled => TRUE,auto_drop => TRUE);
    --delete the program
    exec DBMS_SCHEDULER.drop_program(PROGRAM_NAME => 'RDS2008');
    --Purge the logfile for dbms_scheduler
    exec DBMS_SCHEDULER.PURGE_LOG;
    This is one way as suggested by Trent.
    We can also achieve as follows.
    http://www.dba-oracle.com/t_execute_shell_script_plsql_procedure.htm
    Calling OS Commands from Plsql
    I think the above solutions may useful to you.
    Let me know if you are facing any problem.
    Thanks and Regards
    Maheswara

  • How to call shell script from a pl/sql procedure

    Hi all,
    I am little bit new to plsql programming, i have a small problem as follows
    I have to call a shell script from a pl/sql procedure ..
    Please suggest me some methods in oracle 10g, which i could make use of to achieve my goal. also please tell me what are the constraints for those methods if any.
    I already came across dbms_scheduler, but i have got a problem and its nor executing properly its exiting giving 255 error or saying that permission problem, but i have already given full access to my shell scripts.
    Thanks in advance
    Best Regards
    Satya

    Hi,
    Read this thread, perhaps is there your response :
    Host...
    Nicolas.

  • Calling DTS package from Stored Procedure

    I am getting error calling DTS package from CF.
    So i want to call DTS package from SQL Server Stored
    Procedure.
    DTS package create text file. So no need of input or output
    parameter.
    What is the syntax?.
    thanks for ur help.

    Ted Kruger explains how this can be done in his blog post
    Run SSIS Package from Stored Procedure
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog

  • Calling Shell Script From Java

    Hi i have a shell script which calls the ant command.How do i call this shell script from jdk 1.5. I used p = runtime.exec( filename) but it threw an IOException saying cannot execute. How do i call this from my java program which runs on the redhat linux box.Please Help

    Possibility:
    It does not have execute permissions - Either grant them by chmod or use the command as sh <script-name>
    Rich

  • Call Shell Script from PL-SQL

    Hello All,
    I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
    The different environments I was using before were
    1)
    Operating System (Server) AIX version 5
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    2)
    Operating System (Server) Red Hat Linux 3.4.5-2
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
    and
    reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
    Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
    and I am not getting how to solve the problem.
    I have given all the permissions to users, shell scripts and all as they were before.
    Can you please help?
    Regards,
    Abhijit.

    Hello All,
    I have been using some well known Java Class and Procedures to execute shell scripts from PL-SQL.
    The different environments I was using before were
    1)
    Operating System (Server) AIX version 5
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    2)
    Operating System (Server) Red Hat Linux 3.4.5-2
    Oerating System(Client) Microsoft Windows XP Service Pack 2
    Oracle Database Version Oracle Database 10g Enterprise Edition Release
    10.2.0.1.0
    But suddenly I had to drop and recreate the Databases on 1st (AIX) environment
    and
    reinstall the Operating System (Server) Red Hat 3.4.5-2 on IInd environment stated above (which obviously means the reinstallation of Oracle Database there!)
    Now the shell script(through PL-SQL)is executing smoothly for the IInd (Linux) environment[b] but not executing for the Ist (AIX) environment
    and I am not getting how to solve the problem.
    I have given all the permissions to users, shell scripts and all as they were before.
    Can you please help?
    Regards,
    Abhijit.

  • Calling shell script from forms9i

    Hi,
    I have a shell script that inserts records in the table. When I run this shell script in Unix, it runs fine and inserts records in the table.
    But when I run it from forms9i by using HOST command it does everything written in the shell script but inserting records in the table.
    Can anyone tell me why it is not inserting records in the table.
    I will really appreciate you response.
    Thanks,
    Kumar

    IMO when you run the shell script from forms it runs in privileges of App server user and in that shell that why its running as oraias when you run it from forms .. I think the SSO is out of picture in this situation.So you need to find a way of connecting to the in the script.
    Check the TNS names environment varaibles etc for doing this,

  • Calling a perl script from stored procedure

    Can anyone tell me how to call/run a perl script from a stored procedure? If you have a sample code, please include it.
    Thanks in advance

    If you have a web server setup that runs perl, you can do this by using the utl_http package...Here is some code I use to run a perl script and print the results to a web page on our site.
    The in_URL parameter is the address of the perl code(i.e. http://website/path/perlscript?param1=value1&param2=value2 etc)
    PROCEDURE call_perl(in_URL VARCHAR2) IS
    /* This is setup to allow a perl program to be submitted as a batch program
    using the standard Portal batch program.
    Sometimes these jobs take a long time to run, so the timeout value must
    be set to a large value. The default timeout is 60 seconds, which is not long enough. */
    req utl_http.req;
    resp utl_http.resp;
    value VARCHAR2(1024);
    BEGIN
    req := utl_http.begin_request(replace(utl_url.escape(replace(in_URL,'%3A',':')),CHR(13)));
    utl_http.set_transfer_timeout(req, 18000); -- Set timeout to 5 hours for this specific request.
    resp := utl_http.get_response(req);
    LOOP
    utl_http.read_line(resp, value, TRUE);
    htp.p(value);
    END LOOP;
    utl_http.end_response(resp);
    EXCEPTION WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    WHEN utl_http.init_failed THEN
    htp.p('INIT FAILED');
    WHEN utl_http.request_failed THEN
    htp.p('REQUEST FAILED');
    htp.p(NVL(utl_http.get_detailed_sqlerrm,' No more detail available.'));
    END;
    If you don't have a web server setup, I don't know offhand how you could do this.
    Laurel

  • Calling shell scripts from within Oracle PL/SQL codes

    Hello,
    We are migrating from informix to Oracle. In our Informix Stored Procedure we
    were able to call Unix Shell Script by executing a 'SYSTEM' command, such as:
    CREATE PROCEDURE magazine(flag1, flag2)
    SYSTEM '/pics2/informix/mag.sh' || flag1 || flag2;
    END PROCEDURE;
    How can I write this in PL/SQL? Is there a simillar command for 'SYSTEM' in PL/SQL?
    Thanks

    Mike,
    Wrong forum, for this question, suggest you ask it in the PL/SQL forum.
    Jim Stern

  • File Ownership while executing sql script from stored procedure

    We have a test_command.sql script which is spooling the result into a file. From database we have one Store Procedure(run_sql) which is
    calling and executing the .sql script.
    When we are calling the sql script directly from the database, i e SQL > @/dccops/test_command.sql it is creating the
    file under the Ownership of OS user which is connected to the system.
    The problem we are facing is when we are executing the stored procedure i e exec run_sql(), the file is creating under
    Oracle User.
    Could u please suggest me a solution inorder to create the output file under the user who is logged to the OS.

    First of all, your usage of IM speak is NOT appreciated. Please do not address anyone as if they were a 12-year old.
    'Our Applcation is in C. So we have to call the procedure to run the sql script.'
    This is just utter nonsense!
    Oracle has Pro*C which allows Embedded SQL in C. There is also OCI (Oracle Call Interface) to call Oracle directly in C, and there is OCCI, to do the same in C++.
    Apart from that, Oracle has Ole DB for Windows platforms, to allow for a .NET compatible interface to Oracle.
    There is NO NEED AT ALL to call PL/SQL to run a SQL script.
    Sybrand Bakker
    Senior Oracle DBA

  • Running Unix script from stored procedure

    At present, I run a unix script to export my data for backup using telnet. I would like my users to run the commands on their own without my help. My users do not know telnet (they have no IT knowledge). So, I plan to create a form using Developer/2000 and let them run the procedure thru a stored procedure.But, my problem is how can a stored procedure call a unix script?

    Hi,
    solution, used by me.
    Create a stored procedure that produces a text file with utl_file. The content of the file is the script you want to execute on your Unix box.
    On your Unix Box write a shell script that scans the utl_file_dir for Files. If a file is in, chmod 744 to grnt execute rights to it and execute it.
    I have a example if you want.
    Start the script with crontab or let it loop with a sleep inside.
    HTH
    Detlev

  • Running a sql script from stored procedure

    Hi everyone!
    Has anybody tell me how to execute a sql script from a stored
    procedure!
    Thanks in advance!
    Sasa

    >
    Hi everyone!
    Has anybody tell me how to execute a .sql file from a stored
    procedure!
    Thanks in advance!
    Sasa Sorry, a .sql file!!

Maybe you are looking for

  • ITunes freezes when i try to open Podcasts library

    Every time i click on Podcasts library, the app freezes!

  • Can't Upgrade from AIR 2.0.2 to 2.0.3 on Vista SP2

    I received notification that my AIR needed to be updated. Each time the installer starts but just hangs in an endless loop. The .log shows that the installer "gets lost" looking for .MSI packages in non-existent folders. I've tried installing from th

  • What happened to my audiobooks?

    I tried to sync my Ipod today and was informed I needed to run an update.  I did so and now I am unable to see any of my audiobooks.  I can see the audiobook folder/file when I click on "more" but it says "No Audiobooks".  I have tons of audiobooks. 

  • Raw Material Consumption Report

    Dear Forum, The users want to generate the report from the system that would give the item wise details of the Raw Material Cosnumption for the Period selected. How could we generate the same and also the users want to reconcile the same with the GL

  • MIRO Invoice Goes to Payment Block

    Hi Posting the MIRO document by default goes to Payment Block. No price difference or error/ Checked Vendor master/Price difference percentage settings. How to make remove the Default payment block settings ? Other than above any other settings? Appr