Please help how to run System commands and batch files thru java program
Sir,
I want execute OS commands like dir,cls..etc and batch files,.exe filesthru java program.
I have tried it sofar thru Runtime.getRuntime().exec("execute.bat");
but it is not working.anybody knows about how to run the system commands thru java please give me the code.
thank you,
regards,
j.mouli
I've seen other posts with this questions, and answers. Unfortunately I didn't pay much attention. But the basic idea is to exec command.com and pass the specifc batch or command as an argument.
Similar Messages
-
Hello to you all,
My Macbook Air won's boot up and upon diagnosis, i realized my startup disk is full to 99% even with 2GB Hard Disk space. It wont also enable me boot into safe mode too.
when i power up, i get this prolong gray screen which wont change screen but remain so. Infact i am handicapped.
Please help as all my work documents and project files are on this machine and i can't afford to loose them all...
Please, should you have any solution please send me the details to [email protected]
Thanks you a millionh times.
Al.The MBA seems to cause several problems to several users on boot ups
On start up my MBA would not boot up the apple logo came on but only a blank screen appeared no fan i followed several start up recommendations but to no avail so I took the MBA to the nearest Apple repair centre again the same symptoms on start up ......very sorry sir you need a new mother board that will be $500 not feeling confidant in the product declined and was going to put it on ebay for spares.
On return home I pressed the start up button and it started normally everything was working fine i decided to reinstall all the software what has caused the problem I have no idea but it is after several attempted reboots it finally started on its own so don't give up if you have this problem it may come to life -
Hi
Is that possible to run system command in indesign javascript?
Becase i need to run a command in run prompt while script running in .indd file.
Any idea please let me knowHi Maciej,
For time being i m already using the execute() only for generating pdf from ps.
In this case i cant able set job option in distiller.
The problem y i m trying to run system command is i need pass some parameters (ie., job option, mypsFile) through my script.
Is there any other sollutions?
Thank and Regards
Christy -
How to write sql command in batch file
hi,
i m using oracle 9i on windows. i want to know how can i write sql command on batch file. i want to use a batch file to use sql command like shutdowm & startup command and any select command too.
so plz tell how can i do it ?
thxssuperdba wrote:
thxs u all , i got it at i wanted to do.
thaks u all for yr precious time.
thxsYou've 67 questions with 63 UNanswered. Please mark this question as "answered" and give points to the users whose answer you accept as "helpful" or "correct"
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
How do i search mapi and invoke it by java program ?
how do i search mapi programme and invoke it by java program ?
plz help ?Write a C/C++ DLL to access MAPI and then use JNI to invoke the functions from Java.
-Aprajit -
How to store a data on txt file through java program
that means i want a coding for write data on txt file using java program.that storing data is stored like this formate,
sathees
krishnan
rama
suresh
Stored on one by one. not like this
sathees krishnan rama suresh.........import java.io.*;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class rsk1{
public static void main (String argv []){
try {
String sr[] = new String[100];
String s1=" ";
int j=0;
DataInputStream in = new DataInputStream(System.in);
OutputStream f1 = new FileOutputStream("file1.txt");
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("book.xml"));
// normalize text representation
doc.getDocumentElement ().normalize ();
System.out.println ("Root element of the doc is " +
doc.getDocumentElement().getNodeName());
NodeList listOfPersons = doc.getElementsByTagName("person");
int totalPersons = listOfPersons.getLength();
System.out.println("Total no of people : " + totalPersons);
for(int s=0; s<listOfPersons.getLength() ; s++){
Node firstPersonNode = listOfPersons.item(s);
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
Element firstPersonElement = (Element)firstPersonNode;
NodeList firstNameList = firstPersonElement.getElementsByTagName("first");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
sr[++j]=((Node)textFNList.item(0)).getNodeValue().trim();
NodeList lastNameList = firstPersonElement.getElementsByTagName("last");
Element lastNameElement = (Element)lastNameList.item(0);
NodeList textLNList = lastNameElement.getChildNodes();
sr[++j]=((Node)textLNList.item(0)).getNodeValue().trim();
NodeList ageList = firstPersonElement.getElementsByTagName("age");
Element ageElement = (Element)ageList.item(0);
NodeList textAgeList = ageElement.getChildNodes();
sr[++j]=((Node)textAgeList.item(0)).getNodeValue().trim();
NodeList stuList = firstPersonElement.getElementsByTagName("stu");
Element stuElement = (Element)stuList.item(0);
NodeList textstuList = stuElement.getChildNodes();
sr[++j]=((Node)textstuList.item(0)).getNodeValue().trim();
}//end of if clause
}//end of for loop with s var
System.out.println("Process completed");
for(int i=1;i<=j;i++)
byte buf[] = sr.getBytes();
byte buf1[] = s1.getBytes();
f1.write(buf);
f1.write(buf1);
f1.close();
}catch (SAXParseException err) {
System.out.println ("** Parsing error" + ", line "
+ err.getLineNumber () + ", uri " + err.getSystemId ());
System.out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
}//end of main -
VB ID3 How to run system command?
I'm looking for help of some mighty VBS guru.
I'd like to have my script run the following command:
php D:\Desktop\01.php
and return whatever it prints as a string.
I realise this may seem little off topic in this forum, so here's
the InDesign background:
In mac version of my script I'm executing a shell command from javascript by 'app.doScript'
this runs a line of AppleScript which executes the shell command. Then the outcome
of it travels the same way to javascript and lets InDesign to process it.
Something of this sort:
shScript = "./ ~/Desktop/01.php";
asScript = "do shell script \"" + shScript + "\"";
myResult = app.doScript (asScript, 1095978087);
It's probably not a clever way of running mySQL query and retrieving the results
but I couldnt think of anything better.
Now I need to do the same on Windows. This is rather difficult for me, because
I know very little about VBS. All google searches on the subject led to some
kind of Windows Scripting Host solution which doesn't seem to be supported by
InDesign VBS interpreter.
Can you help me please?
Thanks
WellerThe following snippet is from a larger script. I hope I got the quoting straight, no PC running here to verify.
app.doScript(
"CreateObject(\"WScript.Shell\").Run \"echo yo!\"",
ScriptLanguage.visualBasic);
Dirk -
How to run system commands from JAVA
Hi Friends,
How to run windows system commands from JAVA
Runtime r=Runtime.getRuntime();
r.exec("dir");
Throwing following Exception
CreateProcess :dir error=2
Thanks in advance
HamsaHi ,
in Windows NT this is not possible, you can use the following :
Runtime r=Runtime.getRuntime();
StringBuffer sbuf = new StringBuffer();
String dir = new String();
java.lang.Process proc = r.exec("cmd /c dir");
InputStream is = proc.getInputStream();
int ch ;
while((ch=is.read() ) != -1)
sbuf.append((char)ch);
is.close();
dir = sbuf.toString();
System.out.println(dir ); -
PLEASE HELP! Quicktime Pro with iMovie and .MPG Files
Hello. Please help me. I'm on a G5. 10.5.3. iMovie 7.1.2 (577) I have a series of .MPG files that I need to import into iMovie to edit, arrange and then export over to iDVD, etc. iMovie does not see the .MPG files. The Apple site states that iMovie sees only MPEG-4 files and DV files. I also own Quicktime Pro 7.5 (149.5). When I open the .MPG file in Quicktime Pro, even though the file plays perfectly, when I select "Export to MPEG-4" so I can create a readable file by iMovie, I get an error message that say's "Failed: Export process terminated unexpectedly (10). Complete frustration. Is there another way I can convert these files so iMovie can see them? What's wrong with my Quicktime Pro? I bought DivX Pro last night. I thought maybe that program would make an iMovie readable file. No luck. I used DivX to convert and it created a DivX file with NO SOUND. Wasted money.
If anyone has any solutions for my problems noted here or possible alternatives so I can achieve what I'm trying to do successfully, PLEASE ADVISE as soon as possible.
Thank you for taking the time to read this and THANKS, in advance, for your help.You'll get a ton of ideas from others so, by no means, don't think that mine will solve your issue. I, personally have fallen in love with [StreamClip|http://www.squared5.com>. It does a ton of stuff.
As for your Error 10, hopefully that's just an "out of space" (on your drive) error and not an I/O error (a problem with the drive reading/writing)
But, you said you have Quicktime Pro and you're going to iMovie so I'd try to make your .MPG files a DV Stream...I think that's what I movie likes.
Anyway try that,
Tom
----- !http://hockeynarrative.files.wordpress.com/2007/09/sharkslogo.gif! -
Hi, I need to implemnt this for my project....
I need to combine XML and HTML file and generate a new HTML file
Sample XML File:
<user>
<txtName>sun</txtName>
<txtAge>21 </txtAge>
</user>
Sample HTML File:
<body>
Name: <input type="text" name="txtName" value=""
Age : <input type="text" Age="txtAge" value=""
</body>
I need a java program to combine the above xml and html files and generate the output in HTML.
Any kind of help is sincerely Appreciated.
Thanks.toucansam wrote:
So you want us to write it for you? It's pretty straight forward, first parse the xml file with the *[best java xml parser|http://www.google.com/search?&q=parsing+xml+in+java]* and then go through the nodes and construct the html with strings and concatination. Then write the file using *[the best java file writer|http://www.google.com/search?hl=en&q=writing+to+a+file+in+java]*.
He would do better to use existing tools that make this easy [http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html|http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html] -
System Administration and Batch File
Hi all,
I linked a batch file to be opened in my pdf file, but every time I open this through the link a message comes up saying "disallowed by your system administrator".
Can anyone show me how to allow the batch file to be opened
ThanksThis is a Security feature. In order to change what can be opened as an attachment, you need to edit the registry. The ETK Preference Reference has the information to edit the registry that you will need.
Attachments -
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 -
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 call a exe or bat file from java program
hi,
i actually want to know that how to call a exe or bat file from program so that i can run them parallely.Try this :
String strCmd = "myFile.bat";
try
Runtime rTime = Runtime.getRuntime();
Process process = rTime.exec(strCmd);
InputStream p_in = process.getInputStream();
OutputStream p_out = process.getOutputStream();
InputStream p_err = process.getErrorStream();
p_in.close();
p_out.close();
p_err.close();
catch(Exception e) {
throw new Exception("Unable to start, "+strCmd);
} -
How to eliminate ^M in files thru java program
Hi guys,
SOS!!!
I need to know how to eliminate ^M from files using a java program. This question was posted many times, but no one answered the question. Does anyone know the answer. Post the answer if anyone knows it.
Thanks guys n gals.You need to create new strings with the /r stripped off
/** Takes a string, and replaces the replace text with new text.
* @param str String to replace into
* @param pattern Pattern of text to replace.
* @param replace What to replace it with.
* @return str with the replace text replaced with the new text.
protected static String replace(String str,String pattern, String replace) {
int s = 0;
int e = 0;
StringBuffer result = new StringBuffer();
while ((e = str.indexOf(pattern, s)) >= 0) {
result.append(str.substring(s, e));
result.append(replace);
s = e+pattern.length();
result.append(str.substring(s));
return result.toString();
}
Maybe you are looking for
-
Key mapping to symbols is incorrect on Asha 303
Hello everyone. I just got a slightly used Asha 303 and noticed that the symbols obtained when you press the lower-left gray arrow key (like colon, slash, plus, parenthesis, etc.) are not those shown on the key caps. (e.g. semicolon is shown on the c
-
I had a "pdf export" plan and upgraded it to "pdf pack" plan and it was charged the full price of the new plan in my credit card. How to get the refund of the non used part of the old plan?
-
[SOLVED] KDE / Dolphin : panel's places doesn't show the label of LVM
i'm not sure if it's a bug or a missing feature in arch but in the panel's places of Dolphin all my LVM partitions are labeled « X GB hard drive » even if they have a real label name. It's just working with non-LVM partition. (In debian dolphin i don
-
Implement as in Apps USER form
Hi all, I am required to change the password like in oracle apps Sysadmin>user with same as username and password text items only. In password text item When -validate- item trigger I wrote PACKAGE BODY change_pwd IS first_entry varchar2(30); procedu
-
How to use 'SBOAddonReg.dll'
Hi,Everyone. I want to use 'SBOAddonReg.dll' and to delete registry. Is it possible although development environment is 'VB.NET2003'? Thanks for help.