Execve: Exec format error to execute shell script

I made job to execute a shell script.
exec dbms_scheduler.create_job (
job_name => 'run_sh',
job_type=>'EXECUTABLE',
job_action=> '/fsoracle/app/oracle/inst2/if_cft/send_file_susin.sh',
start_date=>sysdate + 1/5760,
enabled => TRUE
send_file_susin.sh
#!/bin/ksh
set -v
. /fsutil/ndm/axway/profile
/fsutil/ndm/axway/Synchrony/Transfer_CFT/bin/CFTUTIL << EOJ
CONFIG TYPE=COM,MEDIACOM=TCPIP,FNAME=$CFTTCP
     SEND PART=ZADA,IDF=1363X1364,
          FNAME='/fsoracle/app/oracle/product/rdbms/log/KFG.DD.SHRCOM.HRD.A03',
          NFNAME=KFG.DD.SHRCOM.HRD.A03,
          FLRECL=25,NLRECL=25
     SWAITCAT SELECT='IDTU=="%_CAT_IDTU%"'     
EOJ
This script is well executed in terminal mode, but it threwed error, [ORA-27369: job of type EXECUTABLE failed with exit code: Unknown error STANDARD_ERROR="execve: Exec format error"] when I executed the shell script, send_file_susin.sh.
I changed owners and chmods of some specific files, and t.sh was well executed.
t.sh
#!bin/ksh
/usr/bin/mkdir /tmp/test
I don't know what's wrong with the script, send_file_susin.sh.
Does any know about this? Please, tell me the solution.
Thanks in advance,
Jinbae Kim.

Hi,
Posting this in case anyone else find it.
The key error here is "execve: Exec format error" .
The following things should be checked
- that the shell script is a text file has UNIX line terminators
- that the shell script is set to be executable by the user that the job runs as
- that the shell script begins with a hashbang line - e.g. #!/bin/sh (I suspect this is the problem)
For running external jobs on 10gR2 or below, refer to this post Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files
For running external jobs on 11g and up, please use a credential.
Hope this helps,
Ravi.

Similar Messages

  • SM69-Can't exec external program (Exec format error)

    Hi All,
    I am executing UNIX script on HP-UX system via SM69.
    But getting following error:
    u201CCan't exec external program (Exec format error)
    External program terminated with exit code 1u201D
    Also getting same error with FM-SXPG_COMMAND_EXECUTE & SXPG_COMMAND_EXECUTE
    Can any one guide what is the cause of error.
    Any help will be appreciated.
    Regards

    Check the Sample program. You can test or check the Unix commands using the below program.
    You can use the commands Like LS to list all the files.
    REPORT ZUNIX line-size 400
                    no standard page heading.
    data: unixcom like   rlgrap-filename.  
    "7 full perimission to read
    "7 full permission to change
    "7 full permission to delete
    unixcom = 'CHMOD 777 fillfullpath'.
    data: begin of tabl occurs 500,
            line(400),
          end of tabl.
    data: lines type i.
    start-of-selection.
      refresh tabl.
      call 'SYSTEM' id 'COMMAND' field unixcom
                    id 'TAB'     field tabl[].

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

  • RMAN errors sent to shell script calling RMAN sequence?

    Hello,
    I have a Korn shell script run on Solaris as the root user that launches RMAN sequences similar to this one:
    #!/bin/ksh
    su - oracle -c "export ORACLE_SID=ORCL; rman target / << !
    <rman sequence>
    I am wondering if there is a way to catch the RMAN errors in the shell script?
    If I call SQLplus instead of RMAN, I can use "whenever sqlerror exit sql.sqlcode" and I will retrieve the error code in the shell script from $? - can I do such a thing with RMAN?
    Thank you,
    Adrian

    You could capture the return code *$?* from your RMAN script and if it returns anything other than 0, then you could grep the RMAN log for errors and/or query
    V$RMAN_OUTPUT after the RMAN script executes.

  • Error while executing the script adgetlnxver.sh

    Error while executing the script adgetlnxver.sh on apps&db tier during upgrade from 11.5.9 to 11.5.10.2
    -bash: [: -lt: unary operator expected
    [aptinst@dba5 TINST_dba5]$ sh adapcctl.sh restart
    adapcctl.sh version 115.55
    /u01/app/tinst/tinstappl/ad/11.5.0/bin/adgetlnxver.sh: line 123: [: -lt: unary operator expected
    Apache Web Server Listener :httpd ( pid 8645 ) is running.
    Restarting the Apache Web Server Dedicated HTTP Listener..
    Apache Web Server Listener (PLSQL) :httpd ( pid 8673 ) is running.
    Restarting the Apache Web Server Dedicated PLSQL Listener..
    adapcctl.sh: exiting with status 0
    In adgetlnxver.sh: line 123 says
    if [ ${setflag}x = "x" -a $os = "RH" ]; then
    redhatver=`grep -oP "Enterprise Linux [a-z A-Z 0-9]* release [0-9]+" /etc/redhat-release | sed 's/Enterprise Linux [a-z A-Z 0-9]* release //g'`
    if [ $redhatver -lt 5 ]; then
    LD_ASSUME_KERNEL="2.4.19"
    export LD_ASSUME_KERNEL
    fi
    fi
    Thanks,
    Vamsi

    Hi Vamsi.
    The exactly erro refers to a problems when you try upgrade from these version to 11.5.10.
    Can you read this note and apply solution? The note refers a patch, but the problem is the same.
    After Patch 4334965, adstrtal.sh & adstpall.sh is failing with errors [ID 360046.1]
    BR Rafael Ceolim

  • 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

  • Failed load Kernel Modules | fglrx exec Format Error

    Hello
    after I started my computer this morning it won't load fglrx anymore.
    Yesterday everything worked just fine. But I can still start the xserver without any problem.
    systemctl status systemd-modules-load.serivce outputs:
    systemd-modules-load.service - Load Kernel Modules
       Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
       Active: failed (Result: exit-code) since Tue 2013-08-20 10:59:28 CEST; 20min ago
         Docs: man:systemd-modules-load.service(8)
               man:modules-load.d(5)
      Process: 113 ExecStart=/usr/lib/systemd/systemd-modules-load (code=exited, status=1/FAILURE)
    Aug 20 10:59:28 orz-aa-0 systemd-modules-load[113]: Failed to insert 'fglrx': Exec format error
    Aug 20 10:59:28 orz-aa-0 systemd[1]: systemd-modules-load.service: main process exited, code=exited, status=1/FAILURE
    Aug 20 10:59:28 orz-aa-0 systemd[1]: Failed to start Load Kernel Modules.
    Aug 20 10:59:28 orz-aa-0 systemd[1]: Unit systemd-modules-load.service entered failed state.
    Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
    and modprobe fglrx outputs:
    modprobe: ERROR: could not insert 'fglrx': Exec format error
    Installed are:
    catalyst 13.8-1
    catalyst-utils 13.8-1
    lib32-catalyst-utils 13.8-1
    xorg-bdftopcf 1.0.4-1
    xorg-font-util 1.3.0-1
    xorg-font-utils 7.6-3
    xorg-fonts-alias 1.0.3-1
    xorg-fonts-encodings 1.0.4-3
    xorg-fonts-misc 1.0.1-2
    xorg-luit 1.1.1-1
    xorg-mkfontdir 1.0.7-1
    xorg-mkfontscale 1.1.1-1
    xorg-server 1.14.2-2
    xorg-server-common 1.14.2-2
    xorg-setxkbmap 1.3.0-1
    xorg-twm 1.0.7-1
    xorg-xauth 1.0.7-1
    xorg-xclock 1.0.6-1
    xorg-xhost 1.0.6-1
    xorg-xinit 1.3.2-3
    xorg-xkbcomp 1.2.4-1
    xorg-xmodmap 1.0.7-1
    xorg-xrdb 1.0.9-2
    xorg-xset 1.2.2-2
    I'm really a newbie to arch linux and would appreciate any help.
    Thanks in advance.
    surrz
    Last edited by surrz (2013-08-20 10:53:28)

    I grepped /var/log/Xorg.0.log as suggested by the wiki, here's the results:
    sudo grep '(EE)' /var/log/Xorg.0.log
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    [ 19.890] (EE) fglrx(0): atiddxDriScreenInit failed. Probably kernel module missing or incompatible.
    [fiendfan1@arch ~]$ grep '(WW)' /var/log/Xorg.0.log
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    [ 19.150] (WW) The directory "/usr/share/fonts/OTF/" does not exist.
    [ 19.150] (WW) The directory "/usr/share/fonts/Type1/" does not exist.
    [ 19.150] (WW) `fonts.dir' not found (or not valid) in "/usr/share/fonts/100dpi/".
    [ 19.150] (WW) `fonts.dir' not found (or not valid) in "/usr/share/fonts/75dpi/".
    [ 19.586] (WW) Falling back to old probe method for fglrx
    [ 19.710] (WW) fglrx: No matching Device section for instance (BusID PCI:0@1:0:1) found
    [ 19.812] (WW) fglrx(0): board is an unknown third party board, chipset is supported
    [ 19.889] (WW) fglrx(0): Dynamic Surface Resizing cannot be enabled
    [ 19.890] (WW) fglrx(0): ***********************************************************
    [ 19.890] (WW) fglrx(0): * DRI initialization failed *
    [ 19.890] (WW) fglrx(0): * kernel module (fglrx.ko) may be missing or incompatible *
    [ 19.890] (WW) fglrx(0): * 2D and 3D acceleration disabled *
    [ 19.890] (WW) fglrx(0): ***********************************************************
    [ 19.908] (WW) fglrx(0): Textured Video not supported without DRI enabled.
    [ 20.014] (WW) fglrx(0): Option "VendorName" is not used
    [ 20.014] (WW) fglrx(0): Option "ModelName" is not used
    [ 20.425] (WW) evdev: USB USB Keykoard: ignoring absolute axes.
    I don't know what any of this means, anyone have any ideas?

  • 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

  • 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

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

  • Getting Error while executing shell through Demantra workflow

    Hi All,
    I created  .sh file(shell script) for sftp(transfer file from one instance to another instance) and created new workflow with executable step.
    In command line I have given file path and file name(Example: /folder/data/bin/abc.sh). When I try to run this workflow by clicking start button it is not running. That current step is marked with red color. and below error I am getting.could u please help me
    Error description 'Process terminated with errors ,please check the process logs for more
    information.'
    2013-10-31 05:42:02,307 CET [WFProcess_39] ERROR dpweb.general: ######################################################################################
    2013-10-31 05:42:02,308 CET [Mail_Thread] ERROR workflow.steps: MailThread:run()::No Sender or Reciever
    2013-10-31 05:42:02,323 CET [Mail_Thread] ERROR workflow.steps: MailThread:run()::No Sender or Reciever
    2013-10-31 05:44:00,391 CET [ExeStepExecutionThread] FATAL workflow.general: java.io.IOException: /data/nani/bin/sh: not found
    java.io.IOException: java.io.IOException: /data/nani/bin/sh: not found
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
        at java.lang.ProcessImpl.start(ProcessImpl.java:65)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
        at java.lang.Runtime.exec(Runtime.java:591)
        at java.lang.Runtime.exec(Runtime.java:429)
        at java.lang.Runtime.exec(Runtime.java:326)
        at com.demantra.workflow.step.ExeStep.run(ExeStep.java:336)
        at java.lang.Thread.run(Thread.java:595)
    When I try to run the same script through putty its working fine but not through demantra workflow.

    Dear DeetiNaresh,
    Sorry I don't have a solution for this problem. But I am having this same issue. And this is only hit I have found for this issue in metalink or google. Incase your issue is resolved, it would be of great help to me, if you could post your resolution for this.
    Thanks.

  • Command not found error while executing shell programs in terminal

    I have written one sample shell program.
    while executing shell program in terminal,it shows COMMAND NOT FOUND error.
    How to slove this.

    Post the "Actual" error.  It says more than command not found.
    Post your script.
    Post the output from:
    echo $PATH
    Post the output from:
    which name_of_command_not_found

Maybe you are looking for

  • Adobe Acrobat 8 Pro - Fillable Form

    Attempted to create fillable form from Excel document.  Received message as follows: Adobe Live Designer Designer was unable to locate critical application files.  Please shut down Designer and run the installation (found under Add/Remove Programs in

  • SEVERE: SAAJ0009:  How do I stop stack trace being printed to standard out

    Anyone know why the following stack trace is printed when connection.call(message, endpoint); throws an exception? It happens when the server or web service is offline using jdb I can see that the next statement to execute is the return("FAIL .... bu

  • Can't set up and share a hard drive

    I ' ve just purchased a new Airport extreme, I've set up the network ok, I pluged an external drive to  the airport extreme, when to Airport utility disks, enable file sharing, secure  sharing disks: with accounts and I don't know what to do next? Pl

  • Contacts created in iphone do not synchro to outlook

    Hi everyone, First of all, sorry if this topic is repeated. I have been searching just in case but I did not find it. The problem I have is as follows: the contacts created directly on the iphone are not syncrhonizing with Outlook 2007. So, if I crea

  • Oracle rdf protege plugin and owl

    Does the oracle rdf plugin for protege support writing owl files into oracle rdf storage backend? I tried saving a new protege owl project, and get stack dumps (see below). Thanks In saveKnowledgeBase 1 java.sql.SQLException: Io exception: The Networ