Call batch file from Servlet.
Hi all,
can anybody tell me how to call or run batch file
from Servlet.
Please do hurry.
class RuntimeClass
public static void main(String str[]){
Runtime JVM = Runtime.getRuntime();
try
JVM.exec("abc.bat");
catch(Exception e)
System.out.println("hello");
Hi,
i hope the above program will help.
Similar Messages
-
Call Batch file from MAxl Script
Is it possible to call a windows batch file from a maxl script
If you look at the documentaion you will see there is a shell command available
-
Calling batch file from java Program
I have made the java program in which i have called the batch file.But the problem is this that when i call batch file locally it executes normally but when i try to execute batcvh file from remote machine it doesn't runrather it gives Runtime IO execption.Error123.Can anyone provide me the solution for this?
Not without a lot more information. Like for example how you are trying to execute this remote batch file, the code you are using to do that, what kind of server you have no the remote machine to let you remotely execute code, and so on.
-
Calling HTML file from servlet and vice versa...
i have got few questions..
1- if a site is made in HTML then what should be used to put user login functionality in it, servlets or jsp or other option(specify)?
2- im trying to do with servlets, so when im calling doPost method from HTML page and sending data, everything working fine but because of this the page refreshes and the HTML coding get lost, so how can i stop that from happening if possible, like showing the same page with messege = "Logged in".
3- how can i call an HTML page from servlet?
4- how can i send data from servlet to HTML page?that i m aware of, but when a servlet is called then the page will refresh n it will display the things that you have mentioned in the servlet file n not the things that u have mentioned in HTML file, n the page will be blank if u have not mentioned any HTML coding in servlet file.
so i need to knw how to call back that prev HTML file so that the things i want to display can be displayed, i knw the same can be done by adding the HTML code in servlet file but i would like to know if there is any way to call back the HTML file. -
Calling a batch file from PL/SQL
Is there a way to call a windows batch file from within a stored
program in Oracle?
I need to check for error records in a table and if exists, I
would like to call a batch file that invokes mail server and
sends an error notification to a designated person..
Thanks in advanceRe: Upgrate problem
-
How to call any .tmpl file from servlet by sending some parameters ?
Hi,
I am new to Java Servlet and HTML template language ( anyfile.tmpl).
I have created simple login authentication with user registration for new user.
If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
Thank you.
if (session == null) {
try {
userName = request.getParameter("login");
pwd = request.getParameter("password");
if (!userName.equals("") && !pwd.equals("")) {
try {
//Database connection, data fetching, query execution etc.
// code will go here
while (rs.next()) {
if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
String u_name = userName;
String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
String address = rs.getString("address");
session = request.getSession();
session.setAttribute("user", userName);
String inbox = context.getInitParameter(INBOX);
Template inboxTmpl = new Template(inbox);
* inboxTmpl.setParam("userName", u_name);*
* inboxTmpl.setParam("ph_no", ph_no);*
* inboxTmpl.setParam("address", address);*
* out.println(inboxTmpl.output());*
System.out.println("Login successful..");
break;
rs.close();
pstmt.close();
con.close();
(P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}Where does Template come from?
But its not working.The other day I called the car repair shop. I told them my car did not work and I wanted them to fix it. They asked what was wrong, whether it did not start, whether suspicious sounds were heard, whether the car did not want to brake any longer, whether it gave a smoke from the exhaustion, whether the wind shield was broken, whether the oil was leaking etc. But I insisted just telling them "it doesn't work". -
Is it possible to call a windows batch file from PL/SQL
Hi gurus,
Would require your help.Is it possible to call a windows batch file from PL/SQL??If yes can you give an example for the same or any workaround for the same.
Regards
VijayHi!
Youn need some extproc related entries in you listener.ora and tnsnames.ora file.
*1. In the listener.ora:*
Defining the listener process is done in two parts.
The information contained in each listener differs!!!
The first part is as follows:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = extproc)) <--- *ADD THIS LINE
(ADDRESS = (PROTOCOL = TCP)(HOST = yourhostname)(PORT = 1521))
)The seoncd part is as follows:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = YOUR_GLOBAL_DBNAME)
(ORACLE_HOME = c:\oracle\product\10.2.0) <-- THIS IS YOUR ORACLE_HOME
(SID_NAME = YOUR_SID) <-- SID
(SID_DESC = <--- ADD THIS LINE
(SID_NAME = PLSExtProc) <--- ADD THIS LINE
(ORACLE_HOME = c:\oracle\product\10.2.0) <--- ADD THIS LINE AND EDIT TO YOUR ORACLE_HOME
(PROGRAM = extproc) <--- ADD THIS LINE
(ENV = "EXTPROC_DLLS=ANY") <--- ADD THIS LINE
) <--- ADD THIS LINE
)*2. In the tnsnames.ora you need to add the following entry:*
*(The KEY value entered must be match to the KEY value entered int the listener.ora file!)*
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = extproc))
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)Finally you need to restart your listiner. After restarting there will be a service called "PLSExtProc" in your listener.
This are only examples for extproc configuration, your tnsnames.ora and listener.ora can be differs.
FIRST MAKE MAKE A BACKUP OF YOUR ORIGINAL tnsnames.ora AND listener.ora FILES
For more information please check metalink note 68061.1 "EXTPROC: Creating External Procedures on Windows NT"
Bestr Regards
Norbert -
Is it possible to call a windows batch file from PL/SQL block ??
Hi gurus,
Would require your help.Is it possible to call a windows batch file from PL/SQL block ??If yes can you give an example for the same or any workaround for the same.
Regards
VijayYou didn't specify a database version, but if you are 10g or higher, it's quite straightforward using an external job type in DBMS_SCHEDULER. Funnily enough i'm looking at something similar myself at the moment.
Useful guide to some of the issues here Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files -
I need to call a batch file from java and pass arguments to that Batch file
Hi,
I need to call a batch file from java and pass arguments to that Batch file.
For example say: The batch file(test.bat) contains this command: mkdir
I need to pass the name of the directory to the batch file as an argument from My Java program.
Runtime.getRuntime().exec("cmd /c start test.bat");
How to pass argument to the .bat file from Java now ?
regards,
Krish
Edited by: Krish4Java on Oct 17, 2007 2:47 PMHi Turing,
I am able to pass the argument directly but unable to pass as a String.
For example:
Runtime.getRuntime().exec("cmd /c start test.bat sample ");
When I pass it as a value sample, I am able to receive this value sample in the batch file. Do you know how to pass a String ?
String s1="sample";
Runtime.getRuntime().exec("cmd /c start test.bat s1 ");
s1 gets passed here instead of value sample to the batch file.
Pls let me know if you have a solution.
Thanks,
Krish -
Call ggsci using batch file from windows- get error
i create a script to use ggsci, start manager, extract and replicat.
i have success doing this in my linux.
here is one of my script : start_ext1.sh
cd /u01/app/oracle/ggs
./ggsci <<EOF
start manager
start ext_s
exit
EOF
clear
i have an error when i do this using batch file from windows.
here is the batch file :
@echo off
cd C:\putty
plink.exe -ssh -2 -P 22 [email protected] -pw oracle "./start_ext1.sh"
every time i try to enter ggsci when i run that batch file, i get this error :
./ggsci: error while loading shared libraries: libnnz10.so: cannot open shared object file: No such file or directory
i didn't get this error when i run the script in linux.
is there anybody can help me?
thanks a lot!problem solved!
add : . ./.bash_profile before enter ggsci.
it's worked! :) -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
URGENT:- Running a batch file from java program
Author: pkanury
I am trying to execute a batch file from my java program using RunTime and Process . It can execute any dos command except for a batch file. Can anyone throw
some light ?? My code looks like this .....
cmd = "command.com /c X:\\grits\\scripts\\test.bat"; Runtime rt = Runtime.getRuntime(); Process p = rt.exec(cmd);
The weird part is that p.waitFor() returns a status of 0 implying that the cmd has been executed successfully. But that is not the case. And my batch file is as simple as - type "ADADA" > junk.txt
Any help would be appreciated.I think it should work when you use a String[] array
instead of a single String:
String[] cmd = { "command.com", "/C", "D:\\batch\\do.bat" };
Note: If the batchfile creates any output (i.e. files),
they will be stored in the directory of the application
which calls the batch file, not in d:\batch\... -
How to pass arguments to a batch file from java code
Hi
I have a batch file (marcxml.bat) which has the following excerpt :
@echo off
if x==%1x goto howto
java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
goto end
I'm calling this batch file from a java code with the following line of code:
Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
so ,that invokes the batch file.Till that point its ok.
since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
%1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
%2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
%3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
could someone help me...
if i include these parameters too along with the above line of code i.e
Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
I get the following error :
Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
Message was edited by:
justunme11 - create a java class (Executer.java) for example:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Executer {
public static void main(String[] args) {
try {
for (int i = 0; i < args.length; i++) {
System.out.println(args);
Class<?> c = Class.forName(args[0]);
Class[] argTypes = new Class[] { String[].class };
Method main = c.getDeclaredMethod("main", argTypes);
// String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
//jdk <6
String[] mainArgs = new String[args.length - 1];
for (int i = 0; i < mainArgs.length; i++) {
mainArgs[i] = args[i + 1];
main.invoke(null, (Object) mainArgs);
// production code should handle these exceptions more gracefully
} catch (ClassNotFoundException x) {
x.printStackTrace();
} catch (NoSuchMethodException x) {
x.printStackTrace();
} catch (IllegalAccessException x) {
x.printStackTrace();
} catch (InvocationTargetException x) {
x.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
2 - create a .bat file:
@echo off
java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
Open MS-DOS, and type the following:
set TARGET_CLASS=MyTargetClass
set IN_FILE=in.txt
set OUT_FILE=out.txt
Then run your .bat file (in the same ms dos window)
Hope that Helps -
Run a batch file from demantra workflow
I am trying to run a batch file from demantra's workflow by creating an executable step.
I am getting the following error.
Error description ’’Invalid command line:’’"D:\Oracle Demantra Spectrum\Collaborator\demantra\sop\populate_staging.bat"
I am giving the following value in command line of executable step.
"#application_root#\sop\populate_staging.bat"
The batch file exists in the appropriate folder.
Following code is in the batch file.
sqlldr userid=msdem/msdem@demsbx control=load_item_hier.ctl
Please help me.
ThanksThis should work for you-
Create a batch file on your current server (ODI) and write in the path to the other batch file on the other server.
//Server2completename/D$/Path/yourbatchfile.bat
From ODI call your batch file that you created on the same machine.. which will inturn call the other batch file on a different machine to execute batch client.
Also can you paste the errors that you may be getting.. need to check if you are getting any specific issue related to this.
Thanks
Denzz -
Call batch program from ABAP program
hai guys,
I have created one batch file in WINDOWS NT.
Now i want to call this file from my ABAP program.
How can i do this..is there any FM here..pls let me know.
ambichan.Hi ambichan,
To execute a program on the application server, it really is best if you create an external command (using SM69).
Here is an example call of the program:
* call executable
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = command " Your external program
ADDITIONAL_PARAMETERS = param " Your parameters
OPERATINGSYSTEM = 'WINDOWS NT'
* TARGETSYSTEM = sy-host
* DESTINATION = destination
* STDOUT = 'X'
* STDERR = 'X'
* TERMINATIONWAIT = 'X'
* TRACE =
IMPORTING
STATUS = status
EXITCODE = exitcode
TABLES
EXEC_PROTOCOL = exec_protocol
EXCEPTIONS
NO_PERMISSION = x_no_permission
COMMAND_NOT_FOUND = x_command_not_found
PARAMETERS_TOO_LONG = x_parameters_too_long
SECURITY_RISK = x_security_risk
WRONG_CHECK_CALL_INTERFACE = x_wrong_check_call_interface
PROGRAM_START_ERROR = x_program_start_error
PROGRAM_TERMINATION_ERROR = x_program_termination_error
X_ERROR = x_x_error
PARAMETER_EXPECTED = x_parameter_expected
TOO_MANY_PARAMETERS = x_too_many_parameters
ILLEGAL_COMMAND = x_illegal_command
WRONG_ASYNCHRONOUS_PARAMETERS = x_wrong_async_parameters
CANT_ENQ_TBTCO_ENTRY = x_cant_enq_tbtco_entry
JOBCOUNT_GENERATION_ERROR = x_jobcount_generation_error
OTHERS = x_others.
if sy-subrc <> 0 or exitcode <> 0.
* error dialog only, if caller is a dialog user
if sy-batch is initial.
call function 'DB6_SHOW_SXPG_ERROR'
exporting
command = 'DB6CLP'
parameters = param
server = sy-host
return_code = sy-subrc
exitcode = exitcode
tables
exec_protocol = exec_protocol.
endif.
endif.
With this code, if the user is in dialog mode the output from the external command is displayed to them. Otherwise, you can do what you want with the EXEC_PROTOCOL table which contains the output from the external program.
Hope that helps.
Cheers,
Brad
Maybe you are looking for
-
HR_MAINTAIN_MASTERDATA
hi, can you plz explain me how to use this function module in detail. any code snipet wil be of great help. is it possible to generate a PERNR for a new hire using this function module? regards, Balaji
-
ISE 1.2 web authentication problem with wired clients
Hello, i am having problems with centralized web authentication using a Catalyst 3650X with IOS 15.0.2 SE01 and ISE 1.2. Redirecting the client works fine, but as soon the client opens a web browser and ISE websites open to authenticate the client, t
-
Hi Friends, Instead of display Sheet 1 in the Excel sheet tab(Bex), is there a way we can display Query Name in the excel sheet tab? please let me know. Thanks, KK
-
Hi All, We need a report in following format for current fiscal year. Products go on FIFO basis. I tried deriving the summary sale for for current year (Item wise) but what will be the starting point to pick GR -POs ? I'm unable to devise logic for t
-
Caller ID Manipulation based on called party Area Code
I have a new Sales department and they want to be able to call 6 different areas, in which we have a local presence, and have a local number show up for Caller ID and return calls. I have setup a separate Partition and CSS for these users