473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

PL/SQL function to invoke the UNIX command doesn't create file

Hi,

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
  1.  
  2. int sysrun(char *command)
  3. {
  4. return system(command);
  5. }
  6.  
This function runs fine when caled through a driver function in C, meaning that the shared lib is fine.


In PL/SQL, I have used the following method to invoke a UNIX command:-
Expand|Select|Wrap|Line Numbers
  1.  
  2. create or replace library shell_lib as '/home/ECETRAonsite/oracle/OraHome1/lib/libextproc.so';
  3. /
  4.  
  5.  
  6. create or replace function sysrun (syscomm in varchar2)
  7. return binary_integer
  8. as language C
  9. name "sysrun"
  10. library shell_lib
  11. parameters(syscomm string);
  12. /
  13.  
Now when I call this PL/SQL function to invoke the command, it is run succesfully but does not create the file.

<SQL
Expand|Select|Wrap|Line Numbers
  1.  declare 
  2. rc number;
  3. begin
  4. rc := sysrun('/bin/touch /home/ECETRAonsite/oracle/OraHome1/test/sach');
  5. dbms_output.put_line('Return Code='||rc);
  6. * end;
  7.  
SQL> /
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
  1.  
  2. listener.ora
  3. -------------
  4. LISTENER =
  5. (DESCRIPTION_LIST =
  6. (DESCRIPTION =
  7. (ADDRESS_LIST =
  8. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
  9. )
  10. (ADDRESS_LIST =
  11. (ADDRESS = (PROTOCOL = TCP)(HOST =172.21.161.69 )(PORT = 1521)(KEY = ECTPRF))
  12. )
  13.  
  14. )
  15. )
  16.  
  17. SID_LIST_LISTENER =
  18. (SID_LIST =
  19. (SID_DESC =
  20. (SID_NAME = extproc2)
  21. (ORACLE_HOME = /home/ECETRAonsite/oracle/OraHome1)
  22. (PROGRAM = extproc)
  23. (ENVS = "EXTPROC_DLLS=ANY")
  24.  
  25. )
  26. (SID_DESC =
  27. (SID_NAME = ECTPRF)
  28. (ORACLE_HOME = /home/ECETRAonsite/oracle/OraHome1)
  29. (ENVS = "EXTPROC_DLLS=ANY")
  30. )
  31. )
  32.  
  33.  
  34. tnsnames.ora
  35. -------------
  36. EXTPROC_CONNECTION_DATA =
  37. (DESCRIPTION =
  38. (ADDRESS_LIST =
  39. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
  40. )
  41. (CONNECT_DATA =
  42. (SID = extproc2)
  43. )
  44. )
  45.  
Please suggest what is lacking for this to work properly.

Thanks,
May 17 '07 #1
0 3623

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
0
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this...
7
by: DB_2 | last post by:
Hello, I was trying to load a comma-separated text file to a DB2 table. I believe I have the syntax rigt for the LOAD command. My first question is, how do you actually run it? It is not a...
3
by: Fabian Knopf | last post by:
Hi friends, i have a unix machine PC1 where a database is running ( IBM DB2 V8.1 ) . Then i have another machine PC2 i installed there also ( IBM DB2 V8.1 ). On PC2 i installed unixODBC. To...
4
by: veereshai | last post by:
i want to copy the functions from my source file into a new file...and convert each function into a new object file by compiling it. now, i want to invoke the function using the object file i have...
6
by: Joseph | last post by:
Hi, I am trying to develop a C# application that will run on Windows that will do the following * Select file name to process * FTP the file to a UNIX server * Process this file on UNIX using a...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
11
by: dolphin | last post by:
Hi All! I have a question that how to call a function just using a string. For example There is a .cpp file named a.cpp.There are some functions::fun1() fun2() fun3(). I have another fucntion...
3
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.