[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calling UNIX executable file from Forms 4.5

Posted on 2001-07-12
5
Medium Priority
?
897 Views
Last Modified: 2007-11-27
Can we call UNIX executable from Forms 4.5 on WIN NT? What are the settings are required on local PC and remote UNIX machine?
0
Comment
Question by:shah_rupesh
5 Comments
 
LVL 1

Expert Comment

by:misho2000
ID: 6276566
You can call any executalbe only on server side via
 alias extproc in tnsnames.ora and listener.ora. I don't think that you need to setup something on local machine. The server side should be configure properly based on listener configuration.
0
 

Accepted Solution

by:
lcheecho earned 200 total points
ID: 6288890
Step 1: Create the OSUTIL package at the UNIX machine with the following: (I'm using Oracle8 as example)

set echo on
spool sysDBF_ExternalPROC.log

CREATE OR REPLACE LIBRARY libosint IS
  --  This defines the alias library which registers
  --  the external shared library within the Oracle8
  --  data dictionary.
  -- please replace this with your own $ORACLE_HOME/lib/libosint.so
  '/oracle/app/oracle/product/8.1.5/lib/libosint.so';
/

CREATE OR REPLACE PACKAGE osutil IS

  PROCEDURE RunOsCmd(cmdin IN VARCHAR2, cmdoutput OUT VARCHAR2);
  --  Purpose: External procedure to run an OS command
  --  and capture the results.
  --  Input Arguments:
  --          cmdin - the OS command to run
  --  Output Arguments:
  --          cmdoutput - output value of OS command

  PROCEDURE R_RunOsCmd(acmd IN VARCHAR2);
  --  Purpose: Wrapper used to run the external
  --  procedure, "RunOsCmd". The dbms_output package is
  --  used to print the results.
  --  Input arguments:
  --          acmd - an OS command

end osutil;
/

CREATE OR REPLACE PACKAGE BODY osutil IS
  PROCEDURE RunOsCmd(cmdin IN VARCHAR2, cmdoutput OUT VARCHAR2)
  IS EXTERNAL
    NAME "RunOsCmd"
    LIBRARY libosint
    WITH CONTEXT
    PARAMETERS (CONTEXT,
        cmdin                 STRING,
        cmdin        INDICATOR SHORT,
        cmdin             LENGTH INT,
        cmdoutput             STRING,
        cmdoutput    INDICATOR SHORT,
        cmdoutput         LENGTH INT );

  PROCEDURE R_RunOsCmd(acmd IN VARCHAR2) IS

   cmd_out   VARCHAR2(32767); -- output of OS command
   i         INTEGER;         -- counter variable
   j         INTEGER;         -- counter variable
   len       INTEGER;         -- length of command output
   cnl       CHAR(1) := chr(10); -- "newline" character

  BEGIN

   dbms_output.enable(32767);  -- enable a large output buffer
   RunOsCmd(acmd, cmd_out);    -- call the external procedure

   IF (cmd_out IS NULL) THEN
     dbms_output.put_line('ERROR, bad command or no output returned...');
   ELSE                -- output one line at a time
     len := length(cmd_out);
     i := 1;           -- start at first char
     j := instr(cmd_out,cnl,i,1); -- find first newline char
   LOOP
     dbms_output.put_line(substr(cmd_out,i,j-i)); -- print the line
     IF (j = len) THEN
        EXIT;
     END IF;
     i := j + 1;                  -- start after last newline
     j := instr(cmd_out,cnl,i,1); -- find the next newline
   END LOOP;
   END IF;

end R_RunOsCmd;

END osutil;
/

GRANT EXECUTE ON "SYS"."OSUTIL" TO "PUBLIC";

spool off

Step 2: Personally I prefer to call the UNIX exe thru Oracle Package

     lc_system_command varchar2(1000);
     lc_result varchar2(1000);

-- assign your OS command to variable
                lc_system_command := ....

-- call the system exe
                osutil.runoscmd(lc_system_command, lc_result);

Step 3: From From4.5, call the package to run the UNIX command.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7063549
Hi shah_rupesh,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. If there is no objection or further activity, I will suggest to:

    Accept lcheecho's answer.

shah_rupesh, if you think your question was not answered at all, you can post a new comment here.  Community Support moderators will followup.

Please do not accept this comment as an answer!

EXPERTS: Your input and closing recommendations are REQUESTED.
==========
shah_rupesh -- EE database cleanup volunteer
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7082996
Recommended disposition:

    Accept lcheecho's answer.

DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7091152
Thanks for your help here, Dan.
Finalized,  item closed.
Moondancer - EE Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question