Home » SQL & PL/SQL » SQL & PL/SQL » How to run a batch file in Oracle Pl/sql (Oracle Database 10g Release 10.2.0.1.0 )
How to run a batch file in Oracle Pl/sql [message #418865] Tue, 18 August 2009 23:23 Go to next message
subhadip.chanda
Messages: 64
Registered: May 2007
Member
Hi,

I have a .bat file in my client system,which will open a web page after executing(after double clicking on it).I want to execute the same batch file from my pl/sql block.So,after executing my pl/sql block that .bat file should execute,and it should open the same web page.Can any body suggest me,how to do the same ..

Regards,
Re: How to run a batch file in Oracle Pl/sql [message #418870 is a reply to message #418865] Tue, 18 August 2009 23:46 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
>I have a .bat file in my client system,which will open a web page after executing(after double clicking on it).
>I want to execute the same batch file from my pl/sql block.
>So,after executing my pl/sql block that .bat file should execute,and it should open the same web page.
>Can any body suggest me,how to do the same ..
How does PL/SQL "know" upon which client the batch file exist?
How does PL/SQL "know" the fully qualified path name for *bat file?
How does PL/SQL communicate with client PC; what protocol?
How does PL/SQL have the necessary permission to invoke *bat file?

Unless & until ALL these questions can be answered, no solution is possible.
Re: How to run a batch file in Oracle Pl/sql [message #418872 is a reply to message #418865] Wed, 19 August 2009 00:08 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
This is not the first thread where you ask this question; in your other thread people already told you that PL/SQL and browsing HTML don't match.
Re: How to run a batch file in Oracle Pl/sql [message #418899 is a reply to message #418872] Wed, 19 August 2009 02:03 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Im not 100% that I understand what you are try to accomplish, BUT

You could create an external job which will execute a .bat file(residing on the db server).
The external job itself could be started from a PL/SQL procedure containg a call to dbms_scheduler.run_job.

The .bat file itself can cointain logic for executing tasks/executables on diffrent "servers/clients"

Re: How to run a batch file in Oracle Pl/sql [message #418916 is a reply to message #418899] Wed, 19 August 2009 03:04 Go to previous messageGo to next message
subhadip.chanda
Messages: 64
Registered: May 2007
Member
Yes ,this is my requirenment.Can you provide me some sample code on this..
Re: How to run a batch file in Oracle Pl/sql [message #418927 is a reply to message #418916] Wed, 19 August 2009 03:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Can you search and read a little bit in the documentation instead of relying on others?

Regards
Michel
Re: How to run a batch file in Oracle Pl/sql [message #418993 is a reply to message #418916] Wed, 19 August 2009 09:20 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
subhadip.chanda wrote on Wed, 19 August 2009 01:04
this is my requirenment.


How does PL/SQL "know" upon which client the batch file exist?
How does PL/SQL "know" the fully qualified path name for *bat file?
How does PL/SQL communicate with client PC; what protocol?
How does PL/SQL have the necessary permission to invoke *bat file?

Unless & until ALL these questions can be answered, no solution is possible.
Re: How to run a batch file in Oracle Pl/sql [message #419001 is a reply to message #418916] Wed, 19 August 2009 09:37 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
subhadip.chanda wrote on Wed, 19 August 2009 10:04
Yes ,this is my requirenment.Can you provide me some sample code on this..


No, since it can't be done in PL/SQL.
Re: How to run a batch file in Oracle Pl/sql [message #419156 is a reply to message #419001] Thu, 20 August 2009 02:33 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

This may or may not serve your purpose, thats up for you to decide.

The bat file(residing on the databasserver) has to contain the logic for connecting and running executables on remote "servers".

1. First configure the server so that you can execute external jobs, try this link

Dont forget to grant create external job

2.If everything has been done correctly you should be able to create an external job
BEGIN
DBMS_SCHEDULER.create_job (job_name        => 'MYJOB',
                           job_type        => 'EXECUTABLE',
                           job_action      => 'c:\test.bat',
                           enabled         => FALSE,
                           comments        => 'runs test.bat'
                           );
END;


3. Write a procedure that starts the job
CREATE OR REPLACE PROCEDURE execute_bat_file
IS
 BEGIN
   DBMS_SCHEDULER.run_job ('MYJOB', TRUE);
END execute_bat_file;


Then you can call the execute_bat_file from "whatever", which will start the job and execute the bat file,which in turn can operate on remote "servers".

Done it on hp-ux platform, takes a bit of work thou.
Re: How to run a batch file in Oracle Pl/sql [message #419160 is a reply to message #419156] Thu, 20 August 2009 02:36 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
The problem is that the purpose of the .BAT is to open a browser and display a web page.

That's just not going to work in this case.

Nice, concise summary of how to call an external script with DBMS_SCHEDULER though.
Re: How to run a batch file in Oracle Pl/sql [message #419185 is a reply to message #419160] Thu, 20 August 2009 05:28 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Got a bit curious, did a test on how to open a browser and display a web page on a remote machine.
It's definitely doable

1.Placed a bat file on the remote machine(runorafaq.bat) code:
cmd /k START "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "www.orafaq.com" 


2.Created a task(orafaq) in windows scheduler(remote machine) pointing to executable runorafaq.bat

3.On my local computer, created a bat file(runremote.bat)code:
schtasks /run /s 10.1.1.1  /TN orafaq


Which will start the scheduler remote on 10.1.1.1 and run the task orafaq

The web page gets displayed on the remote machine
Re: How to run a batch file in Oracle Pl/sql [message #419203 is a reply to message #419185] Thu, 20 August 2009 06:34 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Of course it is doable, the point is that the actual displaying of the html page has nothing to do with PL/SQL.
There are several ways to do it; if this is meant to show some status-info on an unattended workstation (hey, I would not like a browser to pop-up on my workstation!), RSS or some Queuing-mechanism seems more fit, for example.
Re: How to run a batch file in Oracle Pl/sql [message #468886 is a reply to message #419203] Mon, 02 August 2010 07:03 Go to previous message
martingh
Messages: 6
Registered: August 2010
Junior Member
let me know how does PL/SQL have the necessary permission to invoke *bat filehow does PL/SQL "know" upon which client the batch file exist and how does PL/SQL "know" the fully qualified path name for *bat file?
Previous Topic: Insert Data
Next Topic: how to synch two oracle databases
Goto Forum:
  


Current Time: Sun Dec 04 22:49:08 CST 2016

Total time taken to generate the page: 0.16532 seconds