Retrieving process id from a batch file
Hi friends,
I am having a problem to retrieve the process id from a batch file. I will give the code which I have written and if anyone can help me it will be grateful. I am having time pressure. Here when I call
Process p = rt.exec("checkExec.bat");
the process is getting created. What I need is "I have to get the process id inside the batch file and then I have to store that process id to a file. My problem is "HOW CAN I GET HOLD OF PROCESS ID". Please give some guidance.
!!!!THANKS IN ADVANCE !!!
PROCESSTEST:
public class ProcessTest {
* @param args
public static void main(String[] args) throws IOException {
Runtime rt = Runtime.getRuntime();
try {
Process p = rt.exec("checkExec.bat");
} catch (IOException e) {
e.printStackTrace();
CHECKEXEC.BAT
cd bin
java duo.CalledProcess
CALLEDPROCESS
public class CalledProcess {
* @param args
public static void main(String[] args) {
try {
Runtime rt = Runtime.getRuntime();
synchronized (rt) {
while(true){
rt.exec("notepad");
long sec = 100000;
rt.wait(sec);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
problem is "HOW CAN I GET HOLD OF PROCESS ID".You can take it from the Operating System using JNI.
Similar Messages
-
How to execute a .sql file from a batch file
Hi all
I've to take backup of a database weekly twice on every wednesday & Friday @ 5pm IST. I've written a hot backup script, which works every well.
now i want to automate the script. ie i want this script to run on wednesday & friday @ 5pm without any human interfearance ie with out actually any1 executing this script.
i created a batch file prod.bak with the following lines
@echo off
set oracle_sid=testdb
set oracle_home=d:\oracle\ora92
sqlplus /nolog
connect sys as sysdba/oracletest@testdb
this batch file when eexecuted connects me to sql prompt.
Now i want to execute my backup script bkp.sql automatically when it is connected to sql prompt.
(i tried with these lines in the above batch file...
call bkp.sql---it just opens the bkp.sql file in notepad & displays the script
start bkp.sql---same as call
connect / as sysdba/pwd@[email protected] --- does not work simply remains a the sql prompt.
At 17:00 /Every:w,f "d:\bkp.sql"---does not work simply remains at the sql promt.)
Can any1 let me know what should i write in the batch file that will execute the bkp.sql file automatically after it gets connected to sql prompt. M using oracle 9i.
I'll manage he time through windows utility of scheduling task.. Let me know how to execute the .sql file from a batch file.
Thanks
TriptiTry
sqlplus "sys/oracletest as sysdba" @bpk.sql
Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
Remember to put an exit at the end of the bpk.sql script. -
How to run 11g Form from a batch file (.bat) !
Hi,
Previously, I run my Form 6i from a batch file (with Windows Schedular Tasks) as below;
E:\orant\bin\ifrun60.exe e:\lock.fmx
This form lock some items on a certain date (with the help of Windows Schedular Task).
How can this possible in Forms 11g ?
Kindly guide !
Regards.
Vick.Well are you talking about doing that on a free standing/developer machine or are you thinking of on the
server? In any case forms6i was a native application and forms11 is a web application that requires weblogic, even on the developer machine.
I think you will have to start from square one describing what you are trying to do.
Soapbox: I really think if forms "went back" to having a native deployment option it would be highly treasured. Here is a case where we are still running 6i for that reason. We have a situation where they interview clients at another location using a laptop. The laptop form brings up successive question screens, which questions are asked of the clients and their responses recorded. If the interview data is lost we cannot bring these people back and do it over. In the meantime the wifi connecting back to the database server can go bad. It can get over-loaded, it can just crap out. The firewalls on the way can decide rightly or wrongly to time the connection out. There's a bunch of ways the connection can get dropped. So what we do is that form saves a copy of the data to the disk in a file before it tries to submit it to the database, which could fail. So we have a backup. Can't easily do that in 11. I have yet to have gotten webutil to work. It's a mobile option that is becoming popular and forms should do it, have the ability for the form to run independently on the client including an ability to save data and of course if you saved it, people will want to be able to sync it back to the database when the client is reconnected. -
Installing Oracle 11gR2 client from a batch file and it returns before done
Hello,
While installing Oracle 11gR2 client on XP and 7 from a batch file. When it launches the OUI from the batch file, it returns to the batch file before the installer finishes. So, there is no way for my script to know when the installer is done, or to glean a return code to test for success. This is particularly annoying...
I've also used the "call" command to force my batch file to wait, to no avail. Anyone have any clues about this one?
Thanks in advance!
--RobertSrini,
Awesome! Worked like a charm.
Many thanks!
--Robert -
Input to an executable jar from a batch file
Hi, I have created an executable jar program to receive the input during runtime from a batch file. I have tried to run the program by passing arguments at runtime but the code doesn't seem to execute. Can anyone help me out to pass an argument to the java program using the batch file. The flow of my project is -> The batch file triggers the executable jar file (I am able to execute till this !) -> The input to the executable jar file should be fetched from the arguments given in the batch file which will be taken as the input for the java program.
My java code prompts the user to enter the data but the batch file when executed executes the code but does not wait for the user input. This is the message my batch file displays when executed.
C:\Users\Administrator\Downloads\BatchTool>java -Xms512M -Xmx512M -jar Program.jar -o true
Enter custom directory :
C:\Users\Administrator\Downloads\BatchTool>PAUSE
Press any key to continue . . .
If I press any key the program exits
Is there an option to give the input via batch code ? My doubt is not in the java code. Its the batch file which triggers the code and i want the batch command which will trigger the input to the code being executed.
Is there a way to give the input to this batch file ?
C:\Users\Administrator\Downloads\BatchTool>java -Xms512M -Xmx512M -jar Program.jar -o true * Can i replace this code with an input for the java code ? *
Edited by: Raja Pandian C on Dec 21, 2012 2:26 PM
Edited by: Raja Pandian C on Dec 21, 2012 2:27 PM -
Process chains from the flat file by using filezilla client version in BI
Hi experts,
please let me know how to create the process chains from flat file by using filezilla client version.
so far, I didn't work with file zilla FTP. can anybody give detailed step by step procedure to find the flat files and download them and creating process chains from that flat file.
Thanks & Regards,
Babu..Hi,
Check these:----
Process chain configuration for Flat file loading
http://wiki.sdn.sap.com/wiki/display/BI/Howtowriteroutinetofetchcurrentday%27sfilename
Regards,
Suman -
Using 10g SQL Plus from a batch file
I installed the Oracle Database 10g Express Client and configured my ODBC and tnsnames.ora settings, and I think I have it all right, because when I open the SQL Command Line I can connect to the database just fine using:
connect <username>/<password>@<database>
However, when I try to log in through a non-SQL command line or batch file using the syntax:
sqlplus <username>/<password>@<database>
I get the error "ORA-12154: TNS:could not resolve the connect identifier specified." That syntax used to work for me with 9.2. Does the functionality still exist in 10.2?
Update #1:
The sqlplus login works from a normal command widow if I first CD C:\XEClient\bin. I still can't get it to work from a batch file, even when I specify the path. Does this mean the batch file command can't find my tnsnames.ora? If so, what environment variable do I need to set? I already have the client directory in the Path and ORACLE_HOME variables.
Update #2:
I started randomly trying every Oracle environment variable I could find a reference to, and found that setting TNS_ADMIN to the C:\XEClient\bin directory worked.
I don't need any responses to this post, so it can be deleted by an admin.
Edited by: user11241849 on Jan 13, 2010 12:05 PMHi Toni,
It is my first post here and I though telepathy already operated here :)
it is Oracle 9 I am talking about.
actually, I have 2 batch files
File 1, lets say the file name is batch1.bat and the contents are
sqlldr user/pwd@tnsname control='Control.ctl' data='data.txt'
File 2, batch2.bat and the contents are
Batch1.bat
Sqlplus user/pwd@tnsname @callproc.sql
Now if I run Batch2.bat, then only the first line to be executed which calling the batch1.bat , the second line (sqlplus) never executed!
Best Regards,
Yousef
Edited by: yousef_bayyari on 10-Nov-2009 06:25 -
Within JBuilder, Reading Environment Variable From a BATCH File
Hi ppl:
Following my scenario without JBuilder. I would like to be able to do the same with JBuilder, so that I can run my application from within.
1. In the DOS window, I run a config.bat file that sets up a whole bunch of environment variables and then calls another script file that sets up another whole bunch to set up environment for a third party API (C++ based).
2. My application uses native methods to call the third party API which uses the environment variables set in step 1.
I know how to set the environment varialbes in JBuilder (Project Parameters, VM). However, I don't know how I can call a batch file that does the same. I don't want to set up the third party variables in JBuilder manually, since the script that sets them up checks on a few things to customize the environment.
I also know how to run a batch file from JBuilder, but that does not set the environment for the application. It seems like the batch file is run in a separate process.
Any ideas?
KamranIt seems like the batch file is run in a separate process.Yes, it is. That's a design feature of Windows. The environment variables that a process creates are available to any subprocess, but when the process ends, the environment variables vanish. That's because they are part of the process, not global variables as you might wish.
So that's why your non-JBuilder scenario works; your C++ program is running in a subprocess of the process that defined the environment variables. And your JBuilder scenario doesn't work because the batch file it runs is in a process whose parent process is Windows, not JBuilder. -
Check oracle db status from windows batch file?
Hi
any body have a batch to do that
i want to check connecting , not just the service
thanks very muchI have a process in batch files (dos programming )which prepare some files then call oracle store procedures, i need to have a way to check >if the database is up(open) before i start my processingHow can I tell if the light will light without turning on the switch?
While it can be done, the simplest & easiest way is to try to connect for real & trap any error which may result from it not working. -
Retrieving certain line from a text file
Hi,
I would like to know on how to read a specific line from a text file using NetBeans IDE 6.1? Below is the content of my text file and my code.I will appreciate if anyone can help. Thank in advance= D
Matrix1.text
<matrix>
rows = 2
cols = 2
1 2
2 4
</matrix>
I would like to retrieve the interger 1,2,2,4.
MyCode.java
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
class Matrix {
double [][] element;
static void getFile(String fileName) throws IOException{
int counter = 0;
BufferedReader br = null;
try{
br = new BufferedReader(new FileReader(fileName));
String line = br.readLine();
while (line != null){
line = br.readLine();
System.out.println(line);
counter ++;
System.out.println("Total line : " + counter);
br.close();
}catch(FileNotFoundException ex){
System.out.println(ex.getMessage());
}Wonders wrote:
Thank for reply=D
Yap the row and column will change but i had already parse these lines into my code. However, i am still figuring on how to get the integer number 1,2,2,4 of the text file using while loop and not include the "</matrix>" in the reading. Can this be done?If the numbers you want are at fixed byte positions in the file that are known ahead of time, you can use java.io.RandomAccessFile to skip to those positions. However, that seems unlikely.
If, as is the more likely case, those are not at fixed positions, you'll have to read everything preceding them. (Note that this is not a Java issue. This is how file I/O works.) You'll need to ignore the lines that are meaningless to you (read those lines and do nothing with them) figure out, by whatever rules you have--line numbers, preceding tokens, whatever--when you're at the lines you do care about, and then read and process those lines accordingly. -
Execute java class from a batch file called from runtime.exec
Hi.
I don´t know if this question fits here.
I wan´t to execute a batch file (on Win XP) with runtime.exec. That batch file will execute another java program.
I have the following code:
Resolutor.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Resolutor {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Runtime r = Runtime.getRuntime();
//String[] command = { "cmd.exe", "/C",".\\lanzar.bat .\\ .\\ 001.res:001.dtt" };
String[] command = { "cmd.exe", "/C",".\\tarea\\lanzar.bat " + args[0] + " " + args[1] + " " + args[2]};
try {
//Process proceso = Runtime.getRuntime().exec("lanzar.bat");
Process proceso = Runtime.getRuntime().exec(command);
InputStream stderr = proceso.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
System.out.println("<ERROR>");
while ( (line = br.readLine()) != null)
System.out.println(line);
System.out.println("</ERROR>");
int exitVal = proceso.waitFor();
System.out.println("EXITVAL: " + exitVal);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}lanzar.bat
java Lanzador %1 %2 %3Lanzador.java
import java.util.Vector;
public class Lanzador {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Repetitiva rpt=new Repetitiva();
String rutaFicheros=args[0];
String rutaResultado=args[1];
String[] ficheros=args[2].split(":");
Vector<String> ficheroDatos=new Vector<String>();
for(int i=0;i<ficheros.length;i++){
ficheroDatos.add(ficheros);
System.out.println(ficheros[i]);
System.out.println("RUTA DE FICHEROS: " + rutaFicheros);
System.out.println("RUTA DE RESULTADOS: " + rutaResultado);
System.out.println("CALCULAR");
rpt.setRepetitiva(ficheroDatos, rutaFicheros, rutaResultado);
rpt.calcular();
}I´ve got Resolutor.class in /res and the other two files (and the rest of the files for running) in /res/tarea.
If I execute /res/tarea/lanzar.bat from the command line everything works fine, it calls java and runs lanzador without problem.
The problem comes when I try to execute the batch file via Resolutor.class. It executes the batch file without problem, but it throws a *java.lang.NoClassDefFoundError: Lanzador* when launching the new java application.
Any ideas of how can I solve that problem. (It must do it via batch file).Well, I tried putting in the bat file java -classpath .\tarea Lanzador %1 %2 %3 and didn´t work.
I ve tried the bat modification, and the directory in x.txt is k:\res instead of k:\res\tarea.
I´ve tried to modifiy it to java .\tarea\Lanzador and didn´t work so I have put a cd like the following and it appears to work.
cd tarea
java Lanzador %1 %2 %3Thanks for the replies. -
How to run a project which gets parameters from a batch file
Hello all,
I use to run a program, which gets parameters only by interactive mode, using a batch file as you can see below:
# myprogram < batchfile.txt
Now, I'm updating its code by SunStudioExpress IDE and I'd like to run it from the batchfile. I have noticed that the project properties window has the option run -> arguments, however this program doesn't accept arguments this way and for changing it, I'd have a hard job.
Does someone know how to run this project and to get its parameters from batchfile?
Regards,
GlauberAh, it appears that when you run the project, "<" is passed as one of the arguments and is not treated as input redirection.
Sorry, it looks like it is not possible to do the redirection; and it looks like a bug to me. Could you please file it through bugs.sun.com? It shouldn't take long as the problem is evident now. -
Problem in connecting to sqlplus from windows batch file (DOS)
Hi All,
We have a new 10g Oracle database installed on windows server. I am trying to write a windows batch file to
1) Connect to SQLPLUS
2) Execute a script
3) Disconnect from SQLPLUS.
Example File Name:- execsql.bat
SET ORACLE_SID=CAUT
SET SCHEMA_IN=%1
SET PASS=DEV
SET script=%2
sqlplus %SCHEMA_IN%/%PASS%@%ORACLE_SID% @%script%
if %errorlevel% NEQ 0 echo ERROR: %ERRORLEVEL% else echo OK
Now if i run this bat file like :- execsql.bat DEV script1.sql
DEV= schema name,
script1.sql = this file contains select * from dual;
The code runs fine, but if i change dual to dual1 the sql error's out but not able to catch the error in the batch file.
Reason why i would like to catch the error is this batch file would be scheduled through Autosys job scheduler and for autosys any exit code >0 is an error. Please help me in rewriting this batch script.
Thanks
Sam.Hello,
What if you run this in SQL*Plus before you run the SELECT:
whenever sqlerror exit failure -
To catch exception from a batch file
Hi,
I am running a batch file using java,the batch file is used for running SQL Loader.It is working OK,but I am unable to catch any exception or sucess message.Can anyone help?
regards,
AnshumanHave your Java main() catch Throwable and then use System.exit(an errror code); inside the catch. Your batch file can then examine the process return code.
-
How to call SQL job step by step from windows batch file
Hi ,
I have a SQL agent job [POC_IOD_RunPkgJob] which is being called from bat file with below command.
Could you please tell me how to call only one step of this job, what command I need to mention in the batch file.
SQLCMD -Sabcwi\SQLI01,51565 -E -Q"exec msdb.dbo.sp_start_job [POC_IOD_RunPkgJob]"Hi RameshDravid,
Regarding your description,though not aware of what is the purposed to call only one step of that job, the below sample can somewhat help to achieve your requirement.
--find the job steps
SELECT
steps.step_id,steps.step_name,steps.subsystem,steps.command
FROM msdb.dbo.sysjobsteps steps
JOIN msdb.dbo.sysjobs jobs
ON steps.job_id = jobs.job_id
WHERE jobs.name = 'youJobName'
--find the command runs in that step, usually that is some command exec stored procedure
SQLCMD -Sabcwi\SQLI01,51565 -E -Q"exec stored procedure found in the above query"
If you have any question, feel free to let me know
Eric Zhang
TechNet Community Support
Maybe you are looking for
-
After scanning a lot, my printer says print cartriges missing or not detected
on my C4240 all in one printer, my printer won't let me print after I scanned a lot of papers, It says print cartrige(s) missing or not detected.
-
Spry Tabbed Panel 2.0 Suggestions/Questions
I've been starting to play around with the Widget Browser on CS4 & CS5 and I am just noticing a few things that I think need to be looked at. 1. I am starting to understand your process for the UI (I actually never realized that was there at first, b
-
I can't find the button to turn on Mobile link in desktop Adobe Reader
Hi, I'm trying to turn on Mobile Link in my Win 7 Desktop Adobe Reading. But I just can't find where to turn it on. I already signed in the adobe reader. On this webstie, it says, in the toolbar, click On. But there is no On in my toolbar. I tried ev
-
Need to add new drop down option in Approval preview screen
Hi All, My requirement is to add new drop down option in Approval preview screen in BID Invitation. Please advice. Thanks, S K.
-
Notifications Search Page (/oracle/apps/fnd/wf/worklist/webui/NotifSearchPG) When search notifications without any conditions, it's very slowly,about 4 minutes then click a notification title to reach detail Page(/oracle/apps/fnd/wf/worklist/webui/No