Solved

Calling UNIX executable file from Forms 4.5

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
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 about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

744 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

9 Experts available now in Live!

Get 1:1 Help Now