Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run External App from Oracle?

Status
Not open for further replies.

harwooddale

Programmer
Feb 7, 2003
40
GB
Hi,
Is it possible to run an application, say FTP from within Oracle?
 
Yes it's possible via external procedure call:
example:
shell_command.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sh(char *);
void sh( char *cmd )
{
int num;
num = system(cmd);
}
----------------
gcc -G -c shell_command.c
ld -r -o shell_command.so shell_command.o

In oracle:
CREATE or replace LIBRARY shell_command_lib is 'FULL_PATH_TO_MY_SCRIPTS/shell_command.so'; /

create or replace procedure shell_command(cmd IN char) as external name &quot;sh&quot; library shell_command_lib language C parameters (cmd string); /

Then you can call the shell_command procedure from whatever PL/SQL.

e.g begin
shell_command('my_shell_script');
end;



The exetrnal_procedure_listener must run:
sample listener.ora:
external_procedure_listener =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= extproc_key)
)
)

sid_list_external_procedure_listener=
(sid_list=
(sid_desc= (sid_name=extproc_agent)
(oracle_home=/ora/oracle/817)
(ENVS = LD_LIBRARY_PATH=FULL_PATH_TO_MY_SCRIPTS)
(program=extproc)
)
)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top