ABAP program to execute shell script !

Hi Friends,
I have created some shell scripts and need to be executed through ABAP prog in order to automate some process. can any one tell me how to execute these scripts through ABAP program? i know that we have to setup those scripts through SM69 but i dont have clear idea about this.can some one tell me step by step how to do this. ur help will be awarded in terms of points.
Thanks

Define the scripts as commands in SM69. Test them in SM69/SM49 to see if they work.
Next, go to SE37, run FM SXPG_COMMAND_EXECUTE, and specify your command there. Does it work?
If yes, you can just code a 'CALL FUNCTION' to this FM in your ABAP program, and you are ready to invoke your script from your ABAP.
For  a list of functions that work with commands (defined in SM69), do a drop-down on SXPG_COMMAND* in SE37.
A sample code may look like this
concatenate zsys_id z_infile z_extfile into parm
    separated by space.
*C_FTP_COMMAND is a script defined in SM49
    CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
      EXPORTING
        COMMANDNAME                   = C_FTP_COMMAND
        ADDITIONAL_PARAMETERS         = parm
        OPERATINGSYSTEM               = SY-OPSYS
      TABLES
        EXEC_PROTOCOL                 = PROT
      EXCEPTIONS
        NO_PERMISSION                 = 1
        COMMAND_NOT_FOUND             = 2
        PARAMETERS_TOO_LONG           = 3
        SECURITY_RISK                 = 4
        WRONG_CHECK_CALL_INTERFACE    = 5
        PROGRAM_START_ERROR           = 6
        PROGRAM_TERMINATION_ERROR     = 7
        X_ERROR                       = 8
        PARAMETER_EXPECTED            = 9
        TOO_MANY_PARAMETERS           = 10
        ILLEGAL_COMMAND               = 11
        WRONG_ASYNCHRONOUS_PARAMETERS = 12
        CANT_ENQ_TBTCO_ENTRY          = 13
        JOBCOUNT_GENERATION_ERROR     = 14
        OTHERS                        = 15.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    else.
      write: /, 'FTP Function module executed with no errors.'.
    ENDIF.

Similar Messages

  • Execute Shell Script through Demantra Workflow

    Hi All ,
    Can we execute shell script from Demantra Workflow ?
    If yes where should we place the shell script file and wat should be the commandline command in the step .
    We have the Demantra installed on a windows server and the workflow manager is on a linux server .
    the batch file on the windows server can be executed through the secure shell from the linux server .
    I am trying to achieve the same through thr demantra workflow
    Appreciate any input on the same .
    Thanks and regards
    Suzy

    Hi,
    Shell script is not supported till Demantra 7.2.0.2 WF.
    I have checked with Oracle team also and reply I got below for your reference:
    QUESTION
    *=========*
    As per your details, shall we conclude like this:
    *"only *.bat and *.exe files can be used in workflow. Demantra standard functionality doe*
    *s not support shell script in workflow"*
    ANSWER
    *=======*
    Hi ,
    The Demantra standard functionality 7.2.0.2 does support shell script in workflow.
    Thanks,
    Asya
    Please review the note#468071.1-Unable to Run EBS Workflows that Call EngineManager.exe in
    You will find this note is referring to the Enhancement Request Bug 6644455-- ANALYTICAL ENGINE
    NOT AVAILABLE ON UNIX/LINUX
    But the enhancement bug exist and I hope it is fixed in Demantra 7.3.
    Tks
    MJ

  • Upgraded ROX filer not executing shell scripts

    Hi all,
    I run ICEWM+ROX filer as my lite desktop but after a recent upgrade, ROX does not execute shell scripts on mouse click. It appears that filetype detection has changed so that all scripts are shown with the shellscript icon, whereas before those without a .sh extension where shown with the kde type "cogwheel".
    Any tips much appreciated.
    My thanks in advance!

    I've found a lot of things I don't like about the latest ROX upgrade... too much caching nowadays in my  opinion.

  • Finding path to source executed shell script

    Hello,
    I have shell script A which executes shell script B. The scripts A and B reside in the same directory.
    Following requirements:
    Scripts A and B need to be source executed.
    The directory where A and B resides should be anywhere.
    The present working directory from where A is executed should be anywhere.
    The directory of scripts A and B may not be defined in $PATH.
    The current shell could be any Bourne or Korn shell, Linux or Unix.
    Problem:
    Let's assume scripts A and B are installed in "/custom".
    The users working directory is /home/oracle and he executes "source /custom/A".
    If script A executes "source ./B", the result would be "source /home/oracle/B", which will fail.
    Possible Solution:
    Since script A is being sourced, $0 will always be the name of the current shell and not the name and path to script A.
    I have not found a universal solution to locate the absolute path of a shell script that is being source executed.
    So I was wondering about defining a variable in script A. e.g. SCRIPT_HOME=./custom. When script A executes "source $SCRIPT_HOME/B" it will work, but then script A needs to be customized by the user.
    I could write a script C that edits script A to search and edit the SCRIPT_HOME variable. For this to work I will have to verify that script C is not source executed, and that script A is in the same directory as C based on $0. This is not a problem..
    The question however is whether I need to create script C, or could simply execute script A with -config argument to edit itself and exit. I would prefer the later case and from what I understand, Unix and Linux do not lock files by default and this should be possible.
    Any comments or suggestions please?
    Thanks!
    Edited by: Dude on Apr 5, 2011 3:59 AM

    The $_ solution is actually very simple:
    $ cat thatsme
    mypath=$(dirname $_)
    echo "$mypath/B"
    $ source /home/oracle/thatsme
    /home/oracle/BI do not need the absolute path of script A. The relative path from my current directory will do as well.
    But, it does not work with an alias:
    $ alias thatsme='source /home/oracle/thatsme'
    $ thatsme
    ./B

  • How to set the time limit to execute shell script

    I am using Runtime exec() method to execute a shell script
    if the script hangs for long time infinitely then how to get the control
    return to the program.
    Thanks in advance

    rmi_rajkumar wrote:
    let me explain with an example
    script name is test.sh
    Runtime.exec("test.sh") this will start a new process
    if (proc.waitFor() == 0) {
    try {
    InputStreamReader isr = new InputStreamReader(proc.getInputStream());
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
    outputBuf.append(line).append(ConfigOptions.getLineModeStr());
    } catch (IOException ioe) {
    if test.sh did not exit and hangs with no response
    in this case proc.waitFor() will not execute try catch the control will remain if statement
    my question is insteadof waiting indefinitely need to set a time out say 1 hour and kill the process that executed the scriptYou really need to read the article in the link given by another poster. Your code will not work correctly because you are waiting for the process to end before reading the stream and the processes may never end because you are not reading the stream until after it ends (you need to use muli-threading as explained in the article). If the process really did hange you could probably use destroy(); but, for now, the real problem is your code.

  • Problem executing shell script for rwrun

    hi..
    I wrote a shell script to make a report similar to the batch file in windows.
    My OS is Suse 8.0 with oracle installed in it..
    I have the script like this..I used 2 lexical parameters for my rep file.
    /opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer=\'Ludwigsburg\' and\'
    This one works fine but the one below doesn't give any output. The pdf fiel is just empty. I wonder y,,may be any problems with the spaces or escape characters.I didn't get any error when executed the scripts.
    /opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\'\' whereford=\'protokolle.haendlernummer like \'L%\' and\'
    thanx and waiting for soem one to answer..
    regards
    Kovi

    I solved it by doing the following..
    opt/oracle/OraHome1/bin/rwrun.sh test techy/techy@simone batch=yes desname=test_3.pdf destype=file desformat=pdf atable=\\'\\' whereford=\\'\\ protokolle.haendlernummer\\ like\\ \\'L%\\'\\ and\\'
    from the Java Program..
    Important thing I discoverd is there should be a space at the beginning like whereford=' prot...' and it sok now..
    thanx ...but I still has other probelm now..which is to invoke the report from a servlet which executes this shell script..Problem with DISPLAY variable..I cannot run rwrun.sh without DISPLAY variable..
    Is there any way to set this variable for tomcat service.

  • Can we not run 2 sqlplus programs in a shell script ?

    Hi
    I have 2 spool programs which need to be called from a shell script .
    When i try to do it , only the first spool program runs but not the second one . Is their any reason ?
    #!/usr/bin/bash
    ORACLE_HOME=/oracle10g/product/10.2.0/client_1
    export ORACLE_HOME
    sqlplus -s abcdata/daddy@DevOra < lit_fac.sh > output.log 2>&1
    sqlplus -s abcdata/daddy@DevOra < lit_fac_cat.sh . output_cat.log 2>&1
    exit
    How to run 2 scripts containing select queries each from sqlplus in another shell script ?
    Thanks in advance ..

    user8703472 wrote:
    Hi
    I have 2 spool programs which need to be called from a shell script .
    When i try to do it , only the first spool program runs but not the second one . Is their any reason ?
    #!/usr/bin/bash
    ORACLE_HOME=/oracle10g/product/10.2.0/client_1
    export ORACLE_HOME
    sqlplus -s abcdata/daddy@DevOra < lit_fac.sh > output.log 2>&1
    sqlplus -s abcdata/daddy@DevOra < lit_fac_cat.sh . output_cat.log 2>&1
    exit
    How to run 2 scripts containing select queries each from sqlplus in another shell script ?
    Thanks in advance ..As I said before .. the term "spool program" has no meaning in Oracle and only serves to cloud the issue. I know you are used to using this term with other products, but "When in Rome ...."
    As for your example above, why are you using what appears to be a unix shell script as redirected input into sqlplus? And in the second line, what's with the dot (".") between "lit_fac_cat.sh" and "output_cat.log"?
    If these .sh files are really sql files (which is the only thing sqlplus know how to process) then the proper things to do are
    1) name them lit_fac.sql and lit_fac_cat.sql
    2) feed them to sqlplus in the standard, documented manner:
    sqlplus -s abcdata/daddy@DevOra @lit_fac.sql

  • Host in forms 10g and execute shell script

    Hi!
    I have a little problem. When I transfer form to AS through SSH protocol I want to automatically generate form on AS wit h code:
    declare
    lv_server_dir vc2() := /folder1/folder2;
    lv_file_name vc2():= a.fmb;
    host(lv_server_dir||'/ftp_gen.sh '||lv_server_dir||' '||lv_file_name);
    In file ftp_gen.sh is code:
    export ORACLE_HOME=myOracleHome
    export PATH=$PATH:$ORACLE_HOME/bin
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export SQLPATH=$ORACLE_HOME/dbs
    export NLS_LANG=SLOVENIAN_SLOVENIA.EE8ISO8859P2
    export DISPLAY=:2
    cd $1
    ./gen.sh $3
    When I execute this command on form nothing happens.
    What could be wrong?
    Thanx,
    Bojan

    Hi Bojan,
    Executing the HOST Command will execute in the Mid Tier and nothing will show up in the Client. (other than the form go into Blocking mode). Just check out whether the Operation you wanted to do in the Mid tier is done or not. (Here it looks like you are compiling a form. So, check out that the fmx is generated.)
    Alternatively to check out the proper execution of the HOST command, you can generate a file in the Mid-tier (on successful execution of the shell script) and read the file using TEXT_IO and display a message to user.
    HTH.

  • Execute Shell Script from OWB Process Flow

    I am trying to execute a Shell Script from a User Defined activity of OWB Process Flow. As I have not done such things earlier
    I need to know:
    1. Where I will put the Shell Script (move_file.sh)?
    2. What are the values in need to enter in the external process parameters (such as Command, Script, Result Code, Parameter List, Sucess Threshold etc)
    Please reply this thread. It would be a big help for me and probably for others as well.
    Kind Regards
    Zakir
    Message was edited by:
    Zakir

    Check this out,.
    http://download-uk.oracle.com/docs/cd/B31080_01/doc/owb.102/b28223/ref_processflows.htm#i1173362
    And answer to your question1, the shell script should be on the unix server.
    Regards

  • Problem with executing shell script on linux through java code.

    i am facing problem to kill jboss process on linux that is my application requirement. for that i created one shell script that will get all the process for jboss instance and kill them when i am running that script from command prompt on linux its working perfectly.
    The command i am using ---
    /opt/RW9/jboss/v4.0.5.GA/bin/restartjboss.sh.
    but when i am running through java code its not working.
    the java code i am using is:-
    pp = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", "/opt/RW9/jboss/v4.0.5.GA/bin/restartjboss.sh"});
    could anyone tell me what is the problem ?
    Edited by: akm198110 on Sep 2, 2008 9:24 AM

    I got the problem after long struggle ,after doing proper path i am able to execute the shell script..

  • Need Help on Executing Shell Scripts through PL-SLQ

    Hi All,
    I am trying to execute a shell script from PL-SQL but I am not getting it right .
    the code i used is as follows
    ----JAVA CLASS ---
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (isWindows()) {
    finalCommand = new String[4];
    // Use the appropriate path for your windows version.
    finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
    //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    else {
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    pr.waitFor();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("Process out :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process output.");
    ioe.printStackTrace();
    finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    }).start();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("Process err :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process error.");
    ioe.printStackTrace();
    finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    }).start();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
    return true;
    else
    return false;
    ---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    --- THE SHELL SCRIPT IS -----
    #!/bin/sh
    # This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
    # and the sends the single line stream to the new file with the use of 'gawk' command
    # so finaly the files with same primary name but different secondary name are created
    # e.g. file 'test.DAT1' is onverted to 'test.DAT'
    # LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
    for file_name in `ls /test/*.DAT1`
    do
    new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
    # SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
    gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
    # ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
    # REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
    # $? returns 0 if the call to gawk command is succesfull
    if test 0 = "$?"
         then
         rm -f $file_name
    fi
    done
    # END LOOP ON /test/ DIRECTORY
    ---THE CALL TO THE PROCEDURE --
    SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
    SQL>SET SERVEROUTPUT ON SIZE 1000000
    SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
    now, the statement 1 is the path of the Shell Script ecs_script.sh
    which uses gawk command and does some operations on some file..
    but when i give the call in Statement 1 its giving error like
    /bin/sh is not a directory
    so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
    Please Help.

    @ Bhagat & Michaels
    Dear Friends,
    I changed my shell name as per ur suggestions
    and recompiled the Java class source with
    finalCommand[0] = "/bin/bash"; instead of finalCommand[0] = "/bin/sh";
    and then recompiled the host procedure
    executed the host procedure as per ur suggestion as follows (with out put)
    SQL> exec host('/bin/bash ecs_script.sh')
    PL/SQL procedure successfully completed.
    bt, bt, bt, it still did not do any operations defined in the "ecs_script.sh"
    in fact the script did nt executed.......
    pls help , I am loosing my time..
    regards.

  • Executing shell script through PL/SQL

    Hi,
    I need some help regarding execution of shell script through Oracle PL/SQL.
    I have a shell script present in /abc/xyz folder with name search.sh , Through a PL/SQL procedure I am creating a file to store the report data.
    I want to execute /abc/xyz/search.sh from the PL/SQL procedure to delete all files created before 3 mins .
    1.     At first I took Java route and got following permissions granted for RECON user.
    GRANT USER SYS java.io.FilePermission <<ALL FILES>> execute ENABLED 351
    GRANT USER SYS java.lang.RuntimePermission readFileDescriptor * ENABLED 350
    GRANT USER SYS java.lang.RuntimePermission writeFileDescriptor * ENABLED 349
    2.     Then I created a simple java class for execution of OS command as below
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "OSCommand" AS
    import java.io.*;
    import java.util.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Process proc = Runtime.getRuntime().exec(Command);
    int ext=proc.waitFor();
    return ("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    3.     And a wrapper function as below to use this class
    create or replace
    FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    4.     In my PL/SQL proceedure I am using following code to execute the command
    v_Return := OSCommand_Run('/abc/xyz/search.sh');
    to execute the shell script.
    Proceedure executes without any error and generates a new csv file with report data , however shell script does not get executed and hence all csv files created earlier remain as it is in the folder.
    Please help.

    Sven W. wrote:
    What happens if you remove the catch exception block from your java command?
    I asume you still might have a permission issue. But it could be hidden from you, because of the exception is catched and printed into nirvana.Executed the wrapper function OSCOMMAND_RUN as below
    DECLARE
    v_Return VARCHAR2(2000);
    BEGIN
    v_Return := OSCOMMAND_RUN('/recon/html/invoice/search.sh' );
    DBMS_OUTPUT.PUT_LINE('v_Return = ' || v_Return);
    END;
    And following is the result
    v_Return = 0
    Process exited.
    In case of exception it would had printed the exception.
    One more thing I noticed, even though I have taken following permissions
    GRANT     RECON     SYS     java.io.FilePermission     /abc/*     execute     ENABLED     347
    GRANT     RECON     SYS     java.io.FilePermission     /abc/xyz/*     execute     ENABLED     351
    GRANT     RECON     SYS     java.io.FilePermission     <<ALL FILES>>      execute     ENABLED     352
    GRANT     RECON     SYS     java.lang.RuntimePermission     readFileDescriptor     *     ENABLED     350
    GRANT     RECON     SYS     java.lang.RuntimePermission     writeFileDescriptor     *     ENABLED     349
    When I create a new search.sh in /abc dir I get following error
    v_Return = the Permission (java.io.FilePermission /abc/search.sh execute) has not been granted to RECON. The PL/SQL to grant this is dbms_java.grant_permission( 'RECON', 'SYS:java.io.FilePermission', '/abc/search.sh', 'execute' )
    Edited by: 960702 on Sep 25, 2012 10:34 AM

  • Executing Shell Scripts through PL-SQL

    Hi All,
    I am trying to execute a shell script from PL-SQL but I am not getting it right .
    the code i used is as follows
    ----JAVA CLASS ---
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    if (isWindows()) {
    finalCommand = new String[4];
    // Use the appropriate path for your windows version.
    finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
    //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    else {
    finalCommand = new String[3];
    finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    pr.waitFor();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("Process out :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process output.");
    ioe.printStackTrace();
    finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    }).start();
    new Thread(new Runnable(){
    public void run() {
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("Process err :" + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    catch (IOException ioe) {
    System.out.println("Exception caught printing process error.");
    ioe.printStackTrace();
    finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    }).start();
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    public static boolean isWindows() {
    if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
    return true;
    else
    return false;
    ---PROCEDURE TO BE EXECUTED WHICH USES THE ABOVE JAVA CLASS IS ----
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    --- THE SHELL SCRIPT IS -----
    #!/bin/sh
    # This script removes the carriage returns from the Files having .DAT1 extensions in the /test/ Directory
    # and the sends the single line stream to the new file with the use of 'gawk' command
    # so finaly the files with same primary name but different secondary name are created
    # e.g. file 'test.DAT1' is onverted to 'test.DAT'
    # LOOP on /test/ DIRECTORY FOR SEARCHING FILES HAVING EXTENSION *.DAT1
    for file_name in `ls /test/*.DAT1`
    do
    new_file_name=`echo $file_name | sed 's/DAT1/DAT/'`
    # SEND THE CONTAINTS OF SELECTED FILE IN LOOP AS A CONTINUOUS STREAM TO NEW FILE NAME USING 'gawk' COMMAND
    gawk 'BEGIN { ORS = "''" } { print $0 }' $file_name >> $new_file_name
    # ABOVE LINE WILL CREATE A NEW FILE WITH SAME PRIMARY NAME BUT .DAT AS SECONDARY NAME(EXTENSION)
    # REMOVE THE PRIOR FILE(s) AFTER SUCCESSFUL CALL TO 'gawk'
    # $? returns 0 if the call to gawk command is succesfull
    if test 0 = "$?"
         then
         rm -f $file_name
    fi
    done
    # END LOOP ON /test/ DIRECTORY
    ---THE CALL TO THE PROCEDURE --
    SQL>CALL DBMS_JAVA.SET_OUTPUT(1000000);
    SQL>SET SERVEROUTPUT ON SIZE 1000000
    SQL>exec host('/root/sh ecs_script.sh'); -----------------------------------------------1
    now, the statement 1 is the path of the Shell Script ecs_script.sh
    which uses gawk command and does some operations on some file..
    but when i give the call in Statement 1 its giving error like
    /bin/sh is not a directory
    so i am not getting wHat should I do so that my script "ecs_script.sh" gets executed..
    Please Help.

    The Java proc says:
    > finalCommand[0] = "/bin/sh";
    finalCommand[1] = "-c";
    finalCommand[2] = command;
    You call it as follows:
    SQL>exec host('/root/sh ecs_script.sh');
    The final command will be:
    /bin/sh -c /root/sh ecs_script.sh
    Is this what you intended?

  • Error executing shell script using dbms_scheduler

    I have a job running which executes a shell script,which fails with following error :
    SQL> SELECT additional_info
    2 FROM user_scheduler_job_run_details
    3 WHERE log_date = (SELECT MAX (log_date)
    4 FROM user_scheduler_job_run_details);
    ADDITIONAL_INFO
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    STANDARD_ERROR="mkdir: Failed to make directory "/export/home/bwsolaris/abc"; Permission denied"
    This are contents of my shell script
    #!/bin/ksh
    /bin/mkdir /export/home/bwsolaris/abc
    Can anyone suggest me some way out of it?
    Thanks in advance!!!

    Does oracle still creates a user nobody"nobody" is a "standard" Unix/Linux lowly privileged user, which is used by DBMS_SCHEDULER by default.
    You should change permissions on /export/home/bwsolaris, e.g.
    $ chmod 777 /export/home/bwsolaris
    or use a different directory, where everyone has access, for example /tmp.
    Or take a look at Metalink Note:391820.1 - Scheduled Job Running Shell Script Fails With ORA-27369

  • ORA-01017 encountered while executing shell scripts

    Hi,
    While executing backup scripts for one of my databases, the script contains a login section which fails as shown below
    Script login section:
    sqlplus / << END > /tmp/$PROGRAM.tmp
    Error generatedf in logfile:
    SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 10 11:32:06 2013
    Copyright (c) 1982, 2011, Oracle. All rights reserved.
    ERROR:
    ORA-01017: invalid username/password; logon denied
    Couple of points to be noted:
    1) There are two other databases in the same server and they don't have any issue
    2) I am able to login into this database as "/"
    3) I am able to connect to the same databases as sysdba from another server
    4) The script runs successfully when I modify it as: sqlplus / as sysdba << END > /tmp/$PROGRAM.tmp

    if you connect sqlplus as
    $ sqlplus /You're not identifying that's why you got ORA-01017
    instead if you connect as "sqlplus / as sysdba" , check:
    sqlplus / as sysdba--how it works
    ===========================================
    please mark your threads as answered when you got the correct answer:
          866746     
    Handle:      866746 
    Status Level:      Newbie
    Registered:      Jun 18, 2011
    Total Posts:      3
    Total Questions:      3 (3 unresolved)Edited by: Fran on 12-abr-2013 3:47

Maybe you are looking for

  • To get monday dates in a given date range

    Hi, when a give a date range from Apr 1 to Apr 30 , the query should return all the monday dates from Apr 1 to Apr 30 I.e Apr 4 Apr 11 Apr 18 Apr 25 Please suggest me how to achieve this.

  • Ipod doesn't work on mac

    My ipod shuffle says I need to restore my ipod, but i can't, because I need the adminnistrator's name and password, but I can't get it from him, because were not supposed to download music. Can I get some help?

  • I can't get Safari or Firefox to open certain websites for me

    I am an automotive technician, I have been trying to do some training classes online. The problem I have run into is, Safari comes up with a failure to communicate and if I use Firefox, I get the following message: browserdetectjavaPassThrough.htm is

  • (SOLVED) tango-icon-theme-extra needed ?

    Hi, there tango-icon-theme exists. I installed it on Lxde and it works fine.   However there exists tango-icon-theme-extra. Who can tell me what does this pkg do ? Last edited by ShinChyn (2009-03-26 01:49:14)

  • Aperture cannot export multiple projects for original files

    i want to export projects (original files) to time capsule folder for sharing i can only go into the individual projects, select all, then export to my desire location but i cannot select multiple projects and do it at once, as i have 100+ projects i