I am using Oracle 9i and Unix on my system and trying to execute a UNIX shell command through external procedure in C.
I created a shared lib (libextproc.so) for the following function.
Expand|Select|Wrap|Line Numbers
- int sysrun(char *command)
- {
- return system(command);
- }
In PL/SQL, I have used the following method to invoke a UNIX command:-
Expand|Select|Wrap|Line Numbers
- create or replace library shell_lib as '/home/ECETRAonsite/oracle/OraHome1/lib/libextproc.so';
- /
- create or replace function sysrun (syscomm in varchar2)
- return binary_integer
- as language C
- name "sysrun"
- library shell_lib
- parameters(syscomm string);
- /
<SQL
Expand|Select|Wrap|Line Numbers
- declare
- rc number;
- begin
- rc := sysrun('/bin/touch /home/ECETRAonsite/oracle/OraHome1/test/sach');
- dbms_output.put_line('Return Code='||rc);
- * end;
Return Code=0
PL/SQL procedure successfully completed.
I have verified that the path for 'touch' is correct.
Following are my configuration files.
Expand|Select|Wrap|Line Numbers
- listener.ora
- -------------
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
- )
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST =172.21.161.69 )(PORT = 1521)(KEY = ECTPRF))
- )
- )
- )
- SID_LIST_LISTENER =
- (SID_LIST =
- (SID_DESC =
- (SID_NAME = extproc2)
- (ORACLE_HOME = /home/ECETRAonsite/oracle/OraHome1)
- (PROGRAM = extproc)
- (ENVS = "EXTPROC_DLLS=ANY")
- )
- (SID_DESC =
- (SID_NAME = ECTPRF)
- (ORACLE_HOME = /home/ECETRAonsite/oracle/OraHome1)
- (ENVS = "EXTPROC_DLLS=ANY")
- )
- )
- tnsnames.ora
- -------------
- EXTPROC_CONNECTION_DATA =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
- )
- (CONNECT_DATA =
- (SID = extproc2)
- )
- )
Thanks,