Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling UNIX executable file from Forms 4.5

Posted on 2001-07-12
5
Medium Priority
?
895 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
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.

636 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