Unix Command run successfully through PL/SQL but showing no impact in UNIX.

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.
int sysrun(char *command)
return system(command);
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:-
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);
Now when I call this PL/SQL function to invoke the command, it is run succesfully but does not create the file.
SQL>
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;
SQL> /
Return Code=0
PL/SQL procedure successfully completed.
I have verified that the path for 'touch' is correct.
Following are my configuration files.
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)
Please suggest what is lacking for this to work properly.
Thanks,

No need to create a C wrapper for that kernel call. Simply call the kernel SYSTEM() call direct.
The following works using 10.2.0.1 on HP-UX.
SQL> create or replace library libc as 'libc.2';
2 /
Library created.
SQL>
SQL>
SQL> create or replace function system( command IN string ) return binary_integer is
2 EXTERNAL
3 LIBRARY libc
4 NAME "system"
5 LANGUAGE C
6 CALLING STANDARD C
7 PARAMETERS (
8 command STRING
9 );
10 /
Function created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> -- remove the test file
SQL> ! rm /tmp/plsql-test
SQL>
SQL> declare
2 rc integer;
3 begin
4 rc := system( '/usr/bin/touch /tmp/plsql-test' );
5 DBMS_OUTPUT.put_line( 'return code='||rc );
6 end;
7 /
return code=0
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
SQL> -- display the test file
SQL> ! ls -l /tmp/plsql-test
-rw-r----- 1 oracle dba 0 May 17 14:36 /tmp/plsql-test
SQL>
You may need to define a different library on yours. The kernel shared lib is suppose to be libc.sl - for a reason I cannot recall anymore, I've changed it to use libc.2.
Oh yeah - the system call will be without any environment. Thus you cannot rely on any standard shell environment variables like PATH - you need to fully qualify executables and files (i.e. include the path).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • What are the unix commands w.r.t pl/sql

    How unix commands will help in pl/sql.
    what are those commands,why UNIX ie preferable than windows environment.
    cheers...

    Chinnu wrote:
    How unix commands will help in pl/sql.
    what are those commands,why UNIX ie preferable than windows environment.Unix isn't used in PL/SQL. PL/SQL is a language in it's own right and Unix is the operating system that Oracle can run on.
    Oracle will run quite happily on both Windows and Unix environments (as well as some other *nix specific versions e.g. linux etc.).  Unix is often preferred by people for a server environment as it has a history of being a more stable operating system, but there are plenty who use Windows as a server environment too (we ourselves have both windows and unix servers).
    There are advantages and disadvantages to both. e.g. it is more easy to treat an MS Excel spreadsheet as an external database using an Excel ODBC driver and Oracle Hetereogeneous services if you are using a windows server, whereas on Unix you generally have to purchase a special ODBC driver to cope with Excel files, but likewise Unix has some benefits over Windows aside from the reliability factor.

  • Issue with oracle.odi.sdk.invocation package to run scenario through PL/SQL

    Hi,
    I am new to call ODI scenario through PL/SQL.
    Actually just to test I tried following code-
    1. create or replace and compile java source named "Run_Scen_DCP"
    as
    import oracle.odi.sdk.invocation.*;
    public class Run_Scen_DCP
    public static void Run_Scen()
    OdiCommandScenario cmd = new OdiCommandScenario();
    Output- Warning: execution completed with warning
    and compile Compiled.
    2. create or replace procedure run_scen as language java name 'Run_Scen_DCP.Run_Scen()';
    Output- procedure run_scen Compiled.
    3. EXECUTE run_scen;
    Output- Error starting at line 1 in command:
    EXECUTE run_scen;
    Error report:
    ORA-29541: class TEST_JAVA.Run_Scen_DCP could not be resolved
    ORA-06512: at "TEST_JAVA.RUN_SCEN", line 1
    ORA-06512: at line 1
    29541. 00000 - "class %s.%s could not be resolved"
    *Cause: An attempt was made to execute a method in a Java class
    that had not been previously and cannot now be compiled
    or resolved successfully.
    *Action: Adjust the call or make the class resolvable.
    I am getting the error in calling the wrapper PL/SQL procedure.
    I have set the classpath for SDK jar files C:\oracle\product\11.1.1\Oracle_ODI_1\oracledi.sdk\lib\*.jar
    Please help me understand what I am doing wrong in this.
    Regards,
    Vipin

    Waiting for the solution....

  • Run Unix command / Run Unix shell script from Forms9i

    Hi,
    I have a requirement to run Unix command and Unix shell scripts from Forms9i.
    I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
    Please point me towards any other way to achieve the same.
    I would really appreciate your help.
    Thanks,
    Kumar

    There is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
    The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands.

  • Report runs OK through concurrent program, but not when called through URL

    We have a custom 6i report developed that works successfully 100% of the time when run through a concurrent program.
    We are now attempting to integrate this into an OAF application. To do this, we build the necessary call to the reports server by reading different profile options, etc and come up with a URL like this:
    http://ebsd777.xxxxx.com:8000/dev60cgi/rwcgi60?d777_APPS+report=XXMFG_ESPEC_REPORT.rdf+P_SPEC_ID=43+DESFORMAT=PDF
    This report works 90% of the time when called like this, but the other 10%, we get the following error:
    "Error: The requested URL was not found, or cannot be served at this time.
    Incorrect usage."
    Trying to find what the differences are between the reports that work and those that don't - found that reports which fail seem to extend out further to the right than the reports that do work. But, these reports still fit on standard letter paper in landscape format - as we can verify through the concurrent program call.
    Is there some sort of report server setting or parameter which we can change to get this to work when called through the reports server URL?
    Any thoughts would be appreciated!
    Thanks,
    Craig

    Hi,
    Please post the application release along with the database version and OS.
    But when i call the same program through the pl/sql executable of another concurrent program , it does not print the pdf output by defaultHow do you call the program? What is the value of the number of copies profile option?
    Please see if these docs help.
    Note: 757901.1 - How To Restrict The Number Of Copies To 1?
    Note: 729117.1 - How To Specify the Number of Copies to Print by Report?
    Thanks,
    Hussein

  • How to code: "Goto end if previous command not successful" in PL-SQL?

    I want to proceed with all the remaining statements in a PL-SQL script only if a certain, previous command was executed sucessfully.
    How can I code:
    "Goto end if previous command execution not successful"
    or even better:
    "Goto tag "errorcase" if previous command execution not successful"
    If a goto is not possible maybe an if clause is:
    if (previous command execution not successful) (
    Peter

    user559463 wrote:
    I though that every command writes its exit code into a central system variable like RETURNCODE or ERRORLEVEL.Not in most languages today. They use exceptions.
    What do use return codes are external APIs that one call (as DLLs or shared objects) - such as OpenGL, MAPI, DirectSound, etc.
    But inside a language itself, exceptions are the correct and proper way to deal with errors - not return codes.

  • Command Tab cycles through open apps but does NOT load the window ??

    So I've got several apps running....Mail, Safari, iTunes. I hit command tab and tab over to the program I want and then RELEASE.....The program is displayed at the top of the toolbar but where is my window ??? Its still sitting at the bottom of the tool bar waiting for me to search for it. What gives ? Why isn't command tab doing loading the window ?

    Plenty of people, myself included, don't bother to minimize windows. We just keep everything open.
    Perhaps this article will help you?
    http://lifehacker.com/360537/restore-windows-minimized-to-the-dock
    ~Lyssa

  • I am running Lightroom through the CC, but the CC app shows that I need to install Lightroom ( it is already installed). I am running on a MacBook Pro

    any suggestions?I don't want to reinstall it but I fear I may not be getting updates.

    DMLphotos
    Have  you installed Lightroom 5.7.1 update, you may getting the install option since you have not installed the latest update, check and confirm latest version of Lightroom installed on your computer. If not I would suggest you to go ahead and install Lightroom  5.7.1 from your Creative Cloud App.

  • Running Unix command through Java

    Hi
    I am trying to run the unix command "rf filename" through Java and it doesnt seem to work.
    Can anyone help in this case please
    String cm = "rm ";
    String delFile =  args[0];        // this path is /data/temp/filename.doc
    Process p = Runtime.getRuntime.exec(cmd +delFile);Also since i dont have access to delete the file through my login i always login as root for a few commands.
    Is there a way i can specify user name & password & then run the command?
    Please let me know
    Thanx

    Please discard the above msg i got a solution by just adding file.delete
    thanx

  • Forms and UNIX Commands

    My question is: What is the command that is needed to send a UNIX command from a form generated using the Forms editor? I am trying to create a print button that when pushed in Oracle will generate a lpr command in UNIX and print the window. Thanks.

    It is not as simple as using one command.
    What I have previously done is set up an external procedure (documented in Oracle manuals) and call this external procedure from your form.
    This external procedure must be a C program which will reside on your unix machine which can then call a unix script or whatever.
    I would make sure that your external procedure returns a success or failure flag so that you know if the unix script run successfully (ie the print worked).
    The hardest part to get this working is setting up the external stuff and listener etc so at first, just pass a couple of parameters to write to a unix file first and then when you can call this withouth any problems ..... change it to print.
    Good luck

  • How to transfer the files from one server to another through pl/sql...?

    I want to transfer all the files from source server with respective directory to designation server with respective directory (designation server - oracle reside server).
    Is it possible to ftp from one server to another server(designation server - oracle reside server) through pl/sql. these two servers are independent & unix server.

    No ... The package mentioned in
    http://www.oracle-base.com/dba/miscellaneous/ftp.pks
    this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
    So it is NOT correct that this code transfer the file between two location & with in server..

  • Unix command to turn "off" caps lock or turn it "on" on lab machines

    Hi,
    I'd like to be able to send a unix command to a lab of panther eMacs. I'm using Apple Remote Desktop 3.2 I would like to send both "turn on cap locks" to all the machines, or "turn off cap locks to all the machines.
    Many of my "Send Unix Command" are applescripts (osascript....) so either a unix command or applescript command would be welcome.
    Thanks!

    Well, I've been busy trying some things and found a beautiful little applescript that will turn off caps lock on 10.4 machines and newer. I'll paste it in below. Here's the problem...
    I can't seem to get it to run in ARD as a unix command. (I put the osascript as first line when I pasted it in... This usually works for sending applescript commands)
    So, any ideas on how to get it to run as a unix command??
    IS THERE ANYWAY TO GET THIS TO WORK ON PANTHER MACHINES?? (they don't have the "modify keys..." button in the keyboards and mice pane of sys prefs). The bulk of our machines (over 300 are eMacs running panther).
    *** script ******
    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
    end tell
    tell application "System Events"
    tell application process "System Preferences"
    get properties
    click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
    tell sheet 1 of window "Keyboard & Mouse"
    click pop up button 1
    click menu item "No Action" of menu 1 of pop up button 1
    delay 3
    click button "OK"
    end tell
    end tell
    end tell
    tell application "System Preferences" to quit

  • How to authenticate UNIX command?

    As specified in KB article TS2754 <http://support.apple.com/kb/TS2754> I'd like to use this UNIX command to correct a user's computer:
    dseditgroup -o edit -p -a admin -t group _lpadmin
    I am trying to send this UNIX command via Remote Access 3.3 but each time it says:
    Please enter user password:
    Authentication failed.
    I thought that the fact that I am connected to the computer via Remote Desktop using the admin user and specifying that same admin user in the "Send UNIX Command" command setup would work but it obviously doesn't.
    So how do I properly send this command via Remote Desktop?

    Ack - there's more:
    KB article HT3511 <http://support.apple.com/kb/HT3511> is also relevant since these are networked users with mobile accounts. The problem is the same though: the script causes a prompt for authentication and I don't know how to address that in Remote Desktop.
    This article adds an additional potential issue if I have to send out a UNIX command for each mobile user specifically. It's much nicer when you can send one command to the whole network.

  • Adding Filter to use Unix command

    Hi Experts,
    Where I can get the information about adding the filters for using the Unix commands.
    I have seen the following Filter to use to unix command in one program.
    Eg: open dataset <dsn> for input in text mode filter <b>'dos2ux'</b>.?
    Here "dos2ux" is a filter Unix command they used in that program.
    Please let me know.
    thanks,

    Hi
    You can execute an operating system command in the OPEN DATASET statement using the FILTER addition:
    The following example works under UNIX:
    DATA DSN(20) VALUE '/usr/test.Z'.
    OPEN DATASET DSN FOR OUTPUT FILTER 'compress'.
    OPEN DATASET DSN FOR INPUT FILTER 'uncompress'.
    The first OPEN statement opens the file ‘/usr/test.Z’ so that the displayed data can be read into it in compressed form.
    The second OPEN statement opens the file ‘/usr/test.Z’ so that the data is decompressed when it is read from the file.
    regards
    austin

  • How to show direcotry content in Unix

    Hey
    Greeting,have a simple question for Java Gurus,I am using Tomcat and servlets for my projects running on NT platform connecting to Oracle/Sybase servers on Unix boxes my problem is I want to show directory contents on unix box.. show directory name , filesize, date etc on browser to select file and load into database.
    Please help me with code and ideas, partly or fully.
    Thanks in advance guys.

    If your servlet container is running on NT, the only way to show something on the remote unix is to telneting that unix box. You can look on the telnet task of Ant tool for examples. http://jakarta.apache.org/

Maybe you are looking for