Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: $40 for anyone who can compile Plex for me

Re: $40 for anyone who can compile Plex for me

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/06/19
Message-ID: <33a940e8.2571066@newshost>#1/1

On 19 Jun 1997 04:20:20 GMT, aak2_at_Ra.MsState.Edu (Atif Ahmad Khan) wrote:

>
>I downloaded plex from http://govt.us.oracle.com/
>"downloadable utilities" section. It is supposed to allow
>me to execute Unix system commands from PL/SQL. Oracle did
>not release the binaries but released the source only. I have
>Oracle Workgroup Server 7.3.2.* running under Solaris X86. I
>do not have Pro*C that is required to compile this package.
>

Actually, *I* did not release the binaries. All the downloadable stuff on govt.us.oracle.com is 'freeware', not Oracle software... It is mostly written by people who happen to work at Oracle, but it is not Oracle software..

That aside. It doesn't make sense for somebody else to compile plex for you, nor would it make sense to put binaries up there. Plex is a utility to automate the ability to "call C" from pl/sql using Pipes. If I compiled it and put a plex binary up there, it wouldn't do anything. *You* need to write a C subroutine that needs to be linked into PLEX.

You would need someone to implement the PLEX routine for you from scratch (the host subroutine in C and the host procedure in pl/sql).....

Ok, so can you do this without C? Yes. Here is a PL/SQL subroutine you can install in your schema:

create or replace procedure host( cmd in varchar2 ) as

    status number;
begin

    dbms_pipe.pack_message( cmd );
    status := dbms_pipe.send_message( 'HOST_PIPE' );     if ( status <> 0 ) then raise_application_error( -20001, 'Pipe error' );     end if;
end;
/

Here is a C-Shell script you can run in the background (instead of using the PLEX binary, use this shell script)

sqlplus tkyte/tkyte <<"EOF" | grep '^#' | sed 's/^.//' > tmp.csh  

set serveroutput on  

declare

        status  number;
        command varchar2(255);
begin
        status := dbms_pipe.receive_message( 'HOST_PIPE' );
        if ( status <> 0 ) then
                dbms_output.put_line( '#exit' );
        else
                dbms_pipe.unpack_message( command );
                dbms_output.put_line( '##!/bin/csh -f' );
                dbms_output.put_line( '#' || command );
                dbms_output.put_line( '#exec host.csh' );
        end if;

end;
/
spool off
"EOF"   chmod +x tmp.csh
exec tmp.csh
----------------------- EOF ---------------------------------


If you run this in the background (The script), you'll be able to have it execute any host command you want. Run this in one window for example and in anther window go into sql*plus and try:

SQL> exec host( 'ls -l' );
SQL> exec host( 'uptime' );
SQL> exec host( 'echo Hello World' );
SQL> exec host( 'exit' );

You'll see the output of ls -l, uptime, and echo happen on the other window where the shell script is running (shows you a way to debug pl/sql routines, use "host( echo some string )" and you'll get real time feedback from your pl/sql procedure).....

>I would be willing to pay $40 to anybody who could compile it
>for me under Solaris X86. I know its not much, but will
>probably buy a couple of movie tickets and some pop-corn or
>a nice pair of jeans :)
>

Free... take it, use it if you can. Hope it helps.

>I will post a follow-up as soon as someone sends me email
>saying they have done it.
>
>Thanks.
>
>Atif 'getting pretty desperate to run system commands from PL/SQL' Khan
>aak2_at_ra.msstate.edu

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Jun 19 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US