473,657 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 3642

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

Similar topics

9
4950
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 webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
0
6441
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 tcp/ip port 1555 service with the folowing lines: Send=psef /dj/myco/rf.monitor\r\n Expect=~1 the psef above is a command that the unix server executes. The unix box communicates back a 1 if the test is successful and a 0 if it is
7
7898
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 SQL command; so it doesn't run from the command center/SQL window. It looks like a utility tool but I didn't find a load.exe or db2load.exe file in the installation directory.
3
5734
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 connect to the database over ODBC on unix i did this: on db2 console: catalog tcpip node archiv remote PC1 server DB2_db2inst1
4
2051
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 created and not by invoking the original function(i.e delete the part which has the function and then try to invoke the same function by including the object file into my source code). Is this possible?
6
16379
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 program on UNIX "./pgmname -options Infilename > OutputFilename" * FTP the output of this program back to Windows * Process the resultant file and create output report file
89
6035
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 used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
11
2862
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 void funcall( char *pch). if I pass a argument char* p1="fun1" .How do I call the function fun1() using that string "fun1"that I pass.
3
6727
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 to execute a command call from within Access to execute a batch file (sample.bat). To do this, we use the Shell function, something like: Shell "cmd /c sample.bat"
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.