Link to home
Start Free TrialLog in
Avatar of kiss98770
kiss98770

asked on

Scheduling exe to run in a job with Oracle 10

I am trying to set up an Oracle 10 scheduled job containing 2 steps.   The first step is to run a stored procedure and the second step is to run an exe program.

I've set the schedule up using Oracle Enterprise Manager.   The job starts and runs the first step successfully.    However, the second step just sits there...it doesn't say stalled and CPU used (seconds) stays 0.

Any idea what I could be missing why my exe isn't starting to run?   Is there a better way to schedule this job?

Thanks for your help.
Avatar of sathyagiri
sathyagiri
Flag of United States of America image

Check the permission on your exe.Check the log history to see if you can find any info there
Avatar of schwertner
I do not know a direct way to do this.
One workaround is to use Java in PL/SQL procedure

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
Avatar of kiss98770
kiss98770

ASKER

I found I didn't have the external job schedule service enabled so I've made that change.   I'm still hoping I can use Oracle job scheduler to do this.

However, now my exe does get submitted (I can see it in windows task manager) but it just sits there.  It's not doing any processing (which I can tell from the log file).     The CPU sits at 0%.   If I just click on my pgm to run, it starts and finishes immediately.   Submitting it through the scheduler, it seems to hang.

Any ideas?
Thanks for all your help.
It is not so easy or wasn't.

You can issue unix commands from within a pl/sql procedure if you have oracle 8i or up. do the following:

insert this java procedure into the database:

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "HOST" AS
import java.lang.*;
import java.io.*;

public class Host
{
 public static void executeCommand (String command, String etype) throws IOException
 {
   String[] wFullCommand = {"C:\\winnt\\system32\\cmd.exe", "/y", "/c", command};
   String[] uFullCommand = {"/bin/sh", "-c", command};
   if (etype.toUpperCase().equals("W"))
     Runtime.getRuntime().exec(wFullCommand);
   else if(etype.toUpperCase().equals("U+"))
     Runtime.getRuntime().exec(uFullCommand);
   else if(etype.toUpperCase().equals("U"))
     Runtime.getRuntime().exec(command);
 }
};
/

now compile this pl/sql wrapper procedure in the database:

CREATE OR REPLACE PROCEDURE Host_Command_Proc (p_command  IN  VARCHAR2, p_etype  IN  VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String, java.lang.String)';
/

to issue a unix command to remove all files from a directory for example, you would put this line in your pl/sql procedure:

host_command_proc ('cd home/yourdir/another_dir', 'U+');
host_command_proc ('rm -f *', 'U+');

**note: for this to work you must have the correct java classes loaded in the database.
Hi!

Thanks for those procedures!    I  loaded them and I tried running my 'exe'.    I found my pgm does get loaded and I can see it in Task Manager.   But,  it's not really processing or doing anything.   Normally, if I run my pgm manually, it's just a few seconds and it's done.

Any ideas what I need to do to get job moving?

Thanks so much for your help.
ASKER CERTIFIED SOLUTION
Avatar of schwertner
schwertner
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've granted the securities.   But, my job still just sits there not processing.  I also thought if I had a security problem, my job would fail because of that.    But from windows task manager, I can see it there and CPU is at 0%....nothing is happening.   The job has been submitted but it doesn't seem to be active.

Thanks for much for helping me work through this.
Seems it is a Windows problem.
Try to find solution either using Google
or posting a question in the Windows thread.
Thanks for your help with the java procedures!