Executing a Operating System command from Stored Procedure ??

I want to execute a Operating System command from a PL/SQL Stored Procedure, can anyone suggest me how can I do this ??
I am on Sun-Solaris with Oracle 8.1.7 database.
Please do email me at [email protected]
Thanks in Advance,
Ramesh L.

Are you using a webserver? If so, you could make your operating system script into a CGI program, then execute it from pl/sql using utl_http.request.

Similar Messages

  • How to execute Operating System commands from Stored procedure.

    Any help on how to execute Operating System commands from stored procedures will be appreciated.
    Nanditha.

    Search the forums for 'External Procedure' and you will find example code that has been posted before.

  • Issue with Executing OS commands from Stored Procedure

    I am trying to execute the scripts provided at :
    http://github.com/xtender/XT_SHELL
    provided by xtender user.
    As required, I have asked my DBAs to grant privileges by executing the following scripts:
    Begin
      --change to needed permissions and execute
      dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/factiva/ODS/bin/CVIM_Rpt_ExportCSVFile’, 'read,write,execute' );
    end;
    /where CVIM_Rpt_ExportCSVFile is my script residing in the Unix server where my Oracle is installed.
    The error I am facing when I try to execute the following command is:
    select * from table(xt_shell.shell_exec('/var/scripts/CVIM_Rpt_ExportCSVFile',100))
    Exception:the Permission (java.io.FilePermission /var/scripts/CVIM_Rpt_ExportCSVFile execute) has not been granted to ODS. The PL/SQL to grant this is dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )I have asked my DBA to also execute the following scripts: - But I still see the same error as above. I am not able to figure out whats going on. Can anyone pls help me out??
    EXEC Dbms_Java.Grant_Permission('ODS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC Dbms_Java.Grant_Permission(ODS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )

    DUPLICATE
    ===============================================================
    Issue with Executing OS commands from Stored Procedure
    ==============================================================

  • How to: execute operating system commands from PL/SQL

    System: IBM pSeries AIX
    Oracle: 11g Enterprise
    Is there a quick way to execute operating system commands from PL/SQL?
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.

    Is there a quick way to execute operating system commands from PL/SQL?
    NO
    Without creating a JAVA class....
    I need to execute a Loader script.
    I want to do this from within PL/SQL.
    WHY ON EARTH, such action will create a new connection and become a resource hog?
    I need to to do 4 things.
    Three require SQL scripts.
    The fourth is SQL*Loader.
    The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
    Which is perfect for the purpose.
    Is there way to do all this from within ONE PL/SQL SCRIPT ??
    Just let me know.
    NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
    Sybrand Bakker
    Senior Oracle DBA

  • Calling Operating System Commands from PL/SQL using java

    Calling Operating System Commands from PL/SQL - The Java Way
    wlth help of given thread link,
    Calling OS Commands from Plsql
    but i had user privilege problem
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
    DBMS_OUTPUT.Put_Line(x);
    End;
    o/p;
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    i done the grant privillage also
    part
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    dbms_java.grant_permission('
    abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
    again
    get
    can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
    same error;

    Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
    If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back.

  • Execute external operating system command

    Hi Friends,
    I have a requirement to run a script file with extention '.PL' on the application server using ABAP.
    i have sample how to run it in XI.
    XI3.0 provides a very simple way of handling this using the "Operating System Command" in the File Adapter.
    I post my output file in the following folder,
    /usr/sap/sapout/test/
    The shell script is available in the following path,
    /usr/sap/bin/convert.pl
    The figure below explains as to how we call the shell script using "Operating System Command".
    File Acess parameters
          Target Directory      = /usr/sap/sapout/test/
          File Name Scheme = TestOutput.txt
    Processing Parameters
         File Construction Mode          = Add Time Stamp
         File Type                              = Binary
         Operating System Command = /usr/sap/bin/convert.pl %F
    I have to do the same thing in ABAP as it has been done for XI as mentioned in the above example.
    My operating system is UNIX.
    If any one can give me a sample it would be really helpful to me.
    Thanks in advance,
    Arundhathi.

    Hi Arundhati,
    You can run operating system commands from ABAP.
    e.g. If you want to change UNIX right for any file, you can use following code.
    lv_ucomm  = 'chmod a+rwx 123.txt'.
    CALL 'SYSTEM' ID 'COMMAND' FIELD lv_ucomm.
    whatever command you provide in Field parameter ( lv_ucomm in the above case ), ABAP run that command at operating system level.
    In your case, you can provide command in lv_ucomm to run script at operating system level.
    Hope it will help you.
    Regards,
    Naren

  • Re: Error while Execute External Operating System Command using T.code SM49

    Dear Experts,
    I Have uploaded one .exe file in the application server (eg: sum.exe) and created the OS command in SM69 transaction .
    And maintained the application server path in the 'operating system command' field in SM69 t.code.
    Our SAP system, oprating system is UNIX.
    After I have executed the external command using transaction SM49 , but I got the below error.
    Can not execute external program (permission denied) , External program terminated with exit code 1
    Immediately I run the SU53 transaction code to check the authorization, but Authorization was successful.
    Could any one please help on this error.
    Thanks in advance.

    >>Can not execute external program (permission denied) , External program terminated with exit code 1
    You need to give the permission as 755 to your file.
    >>I Have uploaded one .exe file in the application server (eg: sum.exe)
    You are on UNIX and do not expect to any result of .exe file as UNIX doesn't know about this.

  • Call to Operative System function from DB procedure stored

    I need to call some unix's function just like copy and delete files, but these, in a DB procedure stored...
    there are some package or function (like 'Host()' in sqlplus), for make a call a OS funtions from a DB procedure stored???
    I'm using a Oracle 8.1.5...
    thanks for your help

    Hi,
    If you only need to do file i/o, then use the utl_file package. Otherwise, you might need to use the dbms_pipe package and have a little server program sitting on the other end of the pipe waiting to do operating system tasks. There are many new packages with 8i, look over them before trying the dbms_pipe option.

  • Executing SQLPLUS command from Stored Procedure

    Hi,
    I am trying to execute the SQLPLUS command (CONNECT) from the stored procedure.
    It is throwing below error message.
    Stored Procedure:
    SQL> select user from dual
    2 ;
    USER
    SYS
    SQL> create or replace
    2 PROCEDURE PROCEDURE1 AS
    3 BEGIN
    4 sqlplus sys/sys@D as sysdba;
    5 --execute immediate 'create user 'kkk' identified by 'kkk';
    6 END PROCEDURE1;
    7 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE PROCEDURE1:
    LINE/COL ERROR
    3/9 PLS-00103: Encountered the symbol "SYS" when expecting one of the
    following:
    := . ( @ % ;
    The symbol ":=" was substituted for "SYS" to continue.
    3/22 PLS-00103: Encountered the symbol "AS" when expecting one of the
    following:
    . ( * @ & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
    LIKE4_ LIKEC_ between || member SUBMULTISET_
    The symbol ". was inserted before "AS" to continue.
    Please let me know whether it is possible to do or not.
    If there is possiblility how can does this be done?
    Edited by: NGK246 on Aug 28, 2012 2:21 AM

    NGK246 wrote:
    Hi,
    I am trying to execute the SQLPLUS command (CONNECT) from the stored procedure.
    It is throwing below error message.
    It would not. It will always throw an error. SQLPLUS is a Utility and not a Command/Construct, that it would be available for a Stored Procedure
    >
    SQL> select user from dual
    2 ;
    USER
    SYSWhich Database are you onto? Is it DMIP?
    SQL> create or replace
    2 PROCEDURE PROCEDURE1 AS
    3 BEGIN
    4 sqlplus sys/sys@DMIP as sysdba;
    5 --execute immediate 'create user 'kkk' identified by 'kkk';
    6 END PROCEDURE1;
    7 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE PROCEDURE1:
    LINE/COL ERROR
    3/9 PLS-00103: Encountered the symbol "SYS" when expecting one of the
    following:
    := . ( @ % ;
    The symbol ":=" was substituted for "SYS" to continue.
    3/22 PLS-00103: Encountered the symbol "AS" when expecting one of the
    following:
    . ( * @ & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
    LIKE4_ LIKEC_ between || member SUBMULTISET_
    The symbol ". was inserted before "AS" to continue.
    Please let me know whether it is possible to do or not.
    If there is possiblility how can does this be done?If you are at DMIP, you need not Login again. You can Login Manually to the Database and Execute the Procedure (in which you intend to create a User 'kkk').
    However, if you are trying to Create a User in a Different Database, You will first require a DB Link to exist to connect to the Remote Database. You will also require Explicit privileges to create any user (Although I am not sure if you can create User onto a different Database.)
    I would like to ask you, why are you creating a User on a Remote database? Can you not execute the same procedure on the Remote database and create User? Also, you are using SYS login to perform the activity. Ideally it should not be allowed. You must create a user and grant DBA rights to perform such activities.

  • 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  Operating system command  from PL/SQL programs

    Hi
    Is there any way we call the unix shell script from PL/SQL procedure/functions

    In 10g, it is possible.
    BEGIN
    dbms_scheduler.create_job(job_name => 'myjob',
    job_type => 'executable',
    job_action => '/app/oracle/x.sh',
    enabled => TRUE,
    auto_drop => TRUE);
    END;
    SQL> exec dbms_scheduler.run_job('myjob');
    Documentation:
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#sthref6596
    -aijaz

  • System command execution from stored procedure

    Hello World,
    How to run System command from stored procedure ?
    For example :
    Delete a file
    running a programm,
    Is it possible ?
    H.M

    Years ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
    Never checked if there are other possibilities nowadays.
    cu
    Andreas

  • Execute Unix Mail Command from Store Procedure

    Hi Colleagues!
    I designed a store procedure that Monitoring some Critical tables in my Oracle 8.0.6.1.0 Database But I need to send some Emails from the Store Procedures to Information System Staff when the amount of rows increase too much. I read about UTL_SMTP but my database version is too old to run this package. Also I have the option of Maildemo8i that execute MS Oulook from a Client System But I looking to Send it from my Database(OS HPUX). So please take a look of this issue and I will appreciate any help.
    Your Friend.
    Emmanuel Carrillo Trejos.
    LNB, Republic of Panama(Central America).
    P.D. You can email to: [email protected]

    Do you mean that you want to execute mail or mailx unix commands to send mails.If i am right then probably you are looking for a way to execute operating system commands from your procedure.
    You can refer this link if you want to do that. You need java support in your Oracle database and i believe that Oracle 8 does have jvm running in the instance.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:5079825575573830264::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241
    Thank you!

  • Executing Operating system commands in ABAP

    Hi
    I want to execute a unix operating system command in an ABAP program. I remember seeing code which executes an operating system command. Could any please let me know about that code?
    Thank You.
    Eswar

    Hi,
    you can try something like this.
    data:cmd(254) type c.
    data: RESULT(255) OCCURS 100 WITH HEADER LINE.
                cmd = 'ls'.
    ** Execute command
      REFRESH RESULT.
      CALL 'SYSTEM' ID 'COMMAND' FIELD CMD
                    ID 'TAB'     FIELD RESULT-*SYS*.
    Kostas

  • How does client invoke an operating system command in the Server machine.?

    Guys,
    Is there any way that a client could trigger an operating system command on the Oracle Server machine?
    I've a VB scipt file in the server machine.My requirement is to execute that VB file on the server machine.(The script would essentially create a DSN on the server machine).
    The normal way to execute a VB script would be to specify the name of the file in the command prompt.(If my VB script ONDEMAND.VBS resides in C:\ONDEMAND folder,I need to execute the statement
    "C:\ONDEMAND\ONDEMAND.VBS" in the command prompt to get it executed.)
    I would utilise the SQL command below
    HOST C:\ONDEMAND\ONDEMAND.VBS
    to invoke it programatically(from a PL\SQL scipt).
    Can someone help me in utiliting HOST command in Oracle(Or by any other means) for a client database operation to execute an Operating system command in the Oracle server machine?
    Thanks,
    Bhagat

    Hi Bhagat,
    This has been asked several times recently:
    Executing Shell Script from PL/SQL Block
    Fire an executable using oracle
    Cheers,
    Colin

Maybe you are looking for