Look at external procedures. You write a C program, compile it as a shared object.
You then use Oracle's create library command to tell Oracle about it. You'll need to
setup another listener and change your tnsnames entries as well. I recommend another
listener because the program runs under theas user which started the listener. On
UNIX you should have a second listener under an account less privileged than "oracle".
Even with this you should only allow those commands which are absolutely necessary to
be executed in this manner.
There are good articles on metalink.
Ian MacGregor
Stanford Linear Accelerator Center
[EMAIL PROTECTED]
-----Original Message-----
Sent: Monday, July 09, 2001 4:20 PM
To: Multiple recipients of list ORACLE-L
Seema Singh wrote:
>
> Hi
> How to execute unix command in PL/SQL ?
> Thanks in advance.
> -Seema
You can't. The nearest you can get is to write a daemon program which
waits for commands on a (dbms) pipe, executes them (popen(),
while(fgets()) {}, pclose() in C) and feeds the output back to the pipe.
Needless to say, it can be a serious security gap if you do not screen
the commands, since you are likely to execute them with the privileges
of the user under which the said program is run.
Many moons ago, there used to be something named 'flex' developed by
Oracle consultants and freely available on the web which was more or
less doing that. It may or may not still be around. I have had a look at
it after having developed my own (in Pro*Fortran and under VMS, nothing
stops me - no pipe, but a /OUTPUT=... was appended to the command and I
was reading and sending back the ouput file) and I can tell you that
Flex was unnecessarily complicated. To make simple seems very difficult
to many people.
--
Regards,
Stephane Faroult
Oriole Corporation
Voice: +44 (0) 7050-696-269
Fax: +44 (0) 7050-696-449
Performance Tools & Free Scripts
--------------------------------------------------------------
http://www.oriole.com, designed by Oracle DBAs for Oracle DBAs
--------------------------------------------------------------
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Stephane Faroult
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: MacGregor, Ian A.
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).