Solved

Calling UNIX executable file from Forms 4.5

Posted on 2001-07-12
5
867 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now