PL/SQL to execute exe file with parameters from DB

Hi all,
I have a bit of a problem.
I am in need to write all Logon, Logoff and Logon fail data onto the Windows Application Log. To do this I already tried various solutions but with my configuration (Oracle EE 10.2.0.4 and Windows Server 2003 R2 X64) the only possible solution (apparently) is the following.
I create a Table with the info I need:
CREATE TABLE logonaudittable
event VARCHAR2(15),
sid NUMBER,
serial# NUMBER,
orario DATE,
username VARCHAR2(30),
osuserid VARCHAR2(30),
machinename VARCHAR2(64)
I create a trigger for Logon Data, one for Logoff and one for Logon Fail:
LOGON trigger.
CREATE OR REPLACE TRIGGER logonauditing AFTER LOGON ON database
DECLARE
machinename VARCHAR2(64);
osuserid VARCHAR2(30);
v_sid NUMBER(10);
v_serial NUMBER(10);
CURSOR c1 IS
SELECT sid, serial#, osuser, machine
FROM v$session WHERE audsid = userenv('sessionid');
BEGIN
OPEN c1;
FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
INSERT INTO logonaudittable VALUES ( 'LOGON', v_sid, v_serial, sysdate,
user, osuserid, machinename );
CLOSE c1;
END;
LOGOFF trigger
CREATE OR REPLACE TRIGGER logoffauditing
BEFORE LOGOFF ON database
DECLARE
machinename VARCHAR2(64);
osuserid VARCHAR2(30);
v_sid NUMBER(10);
v_serial NUMBER(10);
CURSOR c1 IS
SELECT sid, serial#, osuser, machine
FROM v$session WHERE audsid = userenv('sessionid');
BEGIN
OPEN c1;
FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
INSERT INTO logonaudittable VALUES ( 'LOGOFF', v_sid, v_serial, sysdate,
user, osuserid, machinename );
CLOSE c1;
END;
LOGON FAIL trigger
CREATE OR REPLACE TRIGGER logonfailauditing
AFTER SERVERERROR ON database
DECLARE
machinename VARCHAR2(64);
osuserid VARCHAR2(30);
v_sid NUMBER(10);
v_serial NUMBER(10);
CURSOR c1 IS
SELECT sid, serial#, osuser, machine
FROM v$session WHERE audsid = userenv('sessionid');
BEGIN
IF (IS_SERVERERROR(1017)) THEN
OPEN c1;
FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
INSERT INTO logonaudittable VALUES ( 'FAILLOGON', v_sid, v_serial, sysdate,
user, osuserid, machinename );
CLOSE c1;
END IF;
END;
The I create a trigger that starts every time something is written on the table.
This trigger needs to start an EXE file that writes the latest data written on the table into the Windows Application Log.
So I need a trigger that executes my WRITELOG.EXE file adding the parameters. For example:
Execute WRITELOG.EXE event sid orario username
So my program will write a Log in Windows with this data:
Event: LOGON
Sid: 2938473
Orario: 12/12/2011 11:45:32
Username: Scott
And so on.
I already have the program that does this, I need to execute the program with the right data directly from trigger or from a procedure executed by my trigger.
Hope I've been clear and REALLY hope someone can help me!!!
Thank you all!

The java and PL/SQL you need to set up is in the very first response in the link. (I don't have a windows Oracle DB DBMS_JAVA to try it myself). Change the UNIX command '/usr/bin/ls' to your Windows command 'c:\yourdirectory\FILE.EXE'. Assuming you created everything and set permissions as Tom describes (later in the thread), your PL/SQL call in your trigger might look something like this:
CREATE OR REPLACE TRIGGER logonauditing AFTER LOGON ON database
DECLARE
machinename VARCHAR2(64);
osuserid VARCHAR2(30);
v_sid NUMBER(10);
v_serial NUMBER(10);
CURSOR c1 IS
SELECT sid, serial#, osuser, machine
FROM v$session WHERE audsid = userenv('sessionid');
BEGIN
OPEN c1;
FETCH c1 INTO v_sid, v_serial, osuserid, machinename;
INSERT INTO logonaudittable VALUES ( 'LOGON', v_sid, v_serial, sysdate,
user, osuserid, machinename );
RUN_CMD('c:\yourdirectory\FILE.EXE LOGON '||v_sid||' '||v_serial||' '||to_char(sysdate,'MM/DD/YYYY')||' '||user||' '||osuserid||' '||machinename);
CLOSE c1;
END;
Since you want to log what the trigger is writing to the table, you can call the executable with the same information you are writing, instead of writing then reading it back out again.

Similar Messages

  • Run a .exe file with parameters from my java code

    Hi, I want to run a .exe file from my java program. This .exe file will take some parameters in the command line. I need
    to supply that to the program as well. Can someone help me in this please?
    Thanks in advance.

    I am trying like this:
    public class lauch_ext {
         public static void main(String[] args) throws Exception{
              try {
                Runtime rt = Runtime.getRuntime();
                Process pr = rt.exec("C:\\Apps\\myapp.exe arg1 -arg2 return_arg");
                BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                String line=null;
                while((line=input.readLine()) != null) {
                    System.out.println(line);
                int exitVal = pr.waitFor();
                System.out.println("Exited with error code "+exitVal);
            } catch(Exception e) {
                System.out.println(e.toString());
                e.printStackTrace();
    }

  • Execute .exe File With Arguments From CaptiveRuntime Air Application

    Hello,
    We have an AIR application compiled as a Captive Runtime app. We need to launch a Native Process (an exe file) on application startup and pass some arguments to that exe. Are there any examples on how to do this? Any resources we can look at for guidence?
    Thanks!

    Hi,
    You need to use Integration technology like BlazeDS or LCDS.

  • How to execute one .exe file with as3 in air ?

    Hi
    How to execute one .exe file with as3 in air?
    I want do this work without fscommand .
    plize help me .

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • Reg : Executing .exe file from application server

    Dear Experts,
                        i have a requirement to execute an .exe file from application server,i tried with method CL_GUI_FRONTEND_SERVICES=>EXECUTE but it executes .exe file from presentation server only.can
    anyone kindly clarify to execute .exe file from application server?
    Thanks in advance,
    Sujay

    Hi,
    Did you search before posting?
    Re: Execute a .exe file present in the Application Server
    Vikranth

  • Labview- .EXE file with excel template

    How to create a .exe file from the .vi file with excel template. Since I am giving only .exe file, the client wont be having the excel templates. So please tell me how to build a .exe file with templates which will be invoked by mainfile.vi. Please let me know if U guys know. (Now in my mainfile.vi I am using local file location path to invoke)

    Hi saamy,
    I have tested it out at my PC and it is working.
    I have tested with MS office report and put the template "Excel Template.xlt" under VI's folder (C:\temp) and make the exe file.
    After the exe file has been moved to other place(C:\build) and has been executed, the exe file try to locate  "Excel Template.xlt" under both C:\temp and C:\build. As long as the template is the same folder with exe file, it is working.
    Pls refer to attached file.
    Hopefully it will help. Please let me know the result.
    Thanks & Regards,
    Steve
    Attachments:
    My Application.zip ‏4415 KB

  • How to create a .exe file with eclipse 3.1

    Hello every body. I want to know how create a .exe file with eclipse 3.1. A friend tell me it's possible but he forgot how ! So I ask my question ay you, how can I do that? I think it's like in Dev-C++, when he compiling the programme he create
    a .exe file but in eclipse, i don't know how do that. Please help me, I have finish some programs but I don't know how create .exe file for give their at my friend.
    Thank's.
    P.S : I'm a young french so maybe there are some mistake on my post. I hope you understand it.

    There might be a plugin in eclipse to do this, but I don't know what it is.
    The normal way to deploy a program is to create an executable jar file. This will be a .jar not a .exe.
    Or you can try ggogle.
    http://www.google.co.uk/search?q=java+exe

  • Executing a file with Java?

    Hi,
    I wanted to know how I could execute a file with java. Here are a couple scenarios - let's say I am developing an anti-spyware utility and I wanted to first write a batch file, and then create it in a folder, then run it when they click "Run". Then afterwards I want to shutdown their computer.
    My Mindset:
    - FileWriter to create the .bat and write the Batch commands.
    - Execute the batch file.
    - Execute the shutdown.exe file to reboot their PC.
    So my simple question is, how can I execute a file?
    Thanks!
    -Josh

    Well here is the code I have:
                try
                    Runtime.getRuntime().exec("cmd.exe /c test.bat");
                catch(IOException e1)
                    //NOTHING
                }Now my cmd.exe is obviously in my Windows System32 folder, and my "test.bat" file is in my C:\ root directory. So I am wondering why that wont execute. I tried a fer other things too like:
    Runtime.getRuntime().exec("cmd.exe  c:\test.bat");that didn't work either, because you can't have a "\" in a string...
    So how can I get this thing to execute the batch file?

  • ADF how can i execute a query with parameters when the page renders

    hi
    i am using ADF web 11g
    i need to execute a query with parameters when the page renders
    thanks

    hello,
    I'm a fan of Java code, I really am.
    But when you use ADF, you decided to move to a more declarative environment.
    So why not do it declarative, the adf way?
    In your pagedef insert a action binding.
    This can be anything, a call to the application module, a call on the iterator(Like executeWithparams, etc.)
    Create an invokeAction in your pagedef and set the condition.
    This example refreshes(Action 2 is execute query) the data.
    First the method binding:
        <action IterBinding="PersoonIterator" id="Execute" InstanceName="LSAppModuleDataControl.Persoon"
                DataControl="LSAppModuleDataControl" RequiresUpdateModel="true" Action="2"/>And the invoke action
        <invokeAction Binds="Execute" id="refreshData"/>This always refreshes the data on page entry, but anything is possible, you can set condictions for the invokeAction.
    -Anton
    PS Yes I know that pagedefs become backing beans in the end and yes that is Java code, but if you wanna play the ADF way, the goal is the reduction of Java code and the increased performance of declarative programming.

  • How To Run An External .exe File With Command Line Arguments

    Hiya, could anyone tell me how I can run an external .exe file with command line arguments in Java, and if possible catch any printouts the external .exe file prints to the command line.
    Thanks.

    Using the Runtime.exec() command. And read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Viewing .exe file with video

    I am trying to extract an exe file with client video that is theirs. Is there a way to extract this? All efforts have failed.

    Any file that comes into your Mac without a proper suffix or extension can appear to the OS to be a .exe. Try changing the extension to .mov, .flv, or .wmv and see what happens.
    fi that does not work, your client must provide you with a proper media file.
    bogiesan

  • Executing exe files from java program

    Hi,
    I need to execute exe files and pass arguments to them from my java code.
    Can you give me guidelines to do that as i haven't done that before.
    Thanks.

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    getRuntime() method.
    exec() method.

  • How to execute ".exe" files using java

    Hi,
      This is guruvulu,
         I have a problem in executing ".exe" files.For Example InternetExplorer.

    Hi,
    You can execute .exe files in JAVA using the following code.
    Runtime rt1 = Runtime.getRuntime();
    Process pc = rt1.exec("someexe.exe");
    you can get the output of the executed exe file in
    in = pc.getInputStream(); //this returns a InputStream
    hope this solves your problem.
    regards,
    P.Venkat

  • Executing  .exe files

    Last week I could not open a .exe file so I tried to pick an application to open it with and it did not work. Now every time I try to open a .exe file it is using this same program that does not work. Does anyone know what I can tell the computer to open .exe files with? Thanks a ton.

    If it is an exe file and your running osx, it's not going to work.
    You can try crossover office (http://codeweavers.com), but that may or may not work.

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

Maybe you are looking for