![]() |
|
|
|||||||
![]() |
Java - Open dos command prompt from java |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi
Is there any way to open the dos command prompt from java (this black dos window...) I want to execute some dos command and to execute them using java code that will run them inside that black dos window... I know I can use... Runtime.getRuntime().exec("run.bat", null); and get a handle to its inputStream however this is not what I want since I want to open that run.bat in the dos prompt ... Tomer Ben-David |
|
|
|
|
#2 |
|
Posts: n/a
|
Tomer Ben-David <> wrote:
> Hi > > Is there any way to open the dos command prompt from java (this black > dos window...) > I want to execute some dos command and to execute them using java code > that will run them inside that black dos window... > > I know I can use... > Runtime.getRuntime().exec("run.bat", null); > and get a handle to its inputStream however this is not what I want > since I want to open that run.bat in the dos prompt ... Execute "cmd.exe /k run.bat" to execute run.bat and keep the command window open afterwards. -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (463 Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |
|
|
|
#3 |
|
Posts: n/a
|
(Tomer Ben-David) wrote in message news:<. com>...
> Hi > > Is there any way to open the dos command prompt from java (this black > dos window...) > I want to execute some dos command and to execute them using java code > that will run them inside that black dos window... > > I know I can use... > Runtime.getRuntime().exec("run.bat", null); > and get a handle to its inputStream however this is not what I want > since I want to open that run.bat in the dos prompt ... its ok I found the solution Runtime.getRuntime().exec("cmd /c start run.bat"); However Now im facing another problem, anyone knows how can I redirect the output of the dos prompt to a file AND as well that it stays in the DOS prompt black screen? Thanks |
|
|
|
#4 |
|
Posts: n/a
|
On 16 May 2004 10:18:44 -0700, (Tomer
Ben-David) wrote or quoted : > >However Now im facing another problem, anyone knows how can I redirect >the output of the dos prompt to a file AND as well that it stays in >the DOS prompt black screen? see http://mindprod.com/jgloss/exec.html -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary. |
|
|
|
#5 |
|
Posts: n/a
|
from the command line use redirection ">" as in
>Dir *.java>javaFiles.txt I suspect, but I do not know, that you'll be able to include this in command lines passed to .getRuntime().exec() as well. You may need to enclose the command line in quotes and use the /S switch as well.. From a dos prompt, try cmd /? for more details on the switches for the cmd executable. I'd be interested in hearing the results of your experiments. -- ROGER NEYMAN "Tomer Ben-David" <> wrote in message news: om... > (Tomer Ben-David) wrote in message news:<. com>... > > Hi > > > > Is there any way to open the dos command prompt from java (this black > > dos window...) > > I want to execute some dos command and to execute them using java code > > that will run them inside that black dos window... > > > > I know I can use... > > Runtime.getRuntime().exec("run.bat", null); > > and get a handle to its inputStream however this is not what I want > > since I want to open that run.bat in the dos prompt ... > > its ok I found the solution > > Runtime.getRuntime().exec("cmd /c start run.bat"); > > > > However Now im facing another problem, anyone knows how can I redirect > the output of the dos prompt to a file AND as well that it stays in > the DOS prompt black screen? > > Thanks |
|
|
|
#6 |
|
Posts: n/a
|
Hi
I found your articles very interesting and very clear! and i looked at the exec utility that simplifies things, and read about the inputstream issue with the process however, I dindnt find any clue whether its possible to direct the output BOTH to a file AND to the console! Im currently going to use, java service wrapper it kind of performing it, it might interest you as well... Roedy Green <look-> wrote in message news:<>. .. > On 16 May 2004 10:18:44 -0700, (Tomer > Ben-David) wrote or quoted : > > > > >However Now im facing another problem, anyone knows how can I redirect > >the output of the dos prompt to a file AND as well that it stays in > >the DOS prompt black screen? > > see http://mindprod.com/jgloss/exec.html |
|
|
|
#7 |
|
Posts: n/a
|
Hi, I played with it and didnt find any way to perform this. I'm
going to use java service wrapper (a simple search for "java service wrapper") will direct you to it, since im going to be using a service as well i found it usefull (and it did print the output of the dos command both to the dos window and to a file...) Tomer "rpnman" <> wrote in message news:<pfPpc.78904$>. .. > from the command line use redirection ">" as in > >Dir *.java>javaFiles.txt > > I suspect, but I do not know, that you'll be able to include this in command > lines passed to .getRuntime().exec() as well. > > You may need to enclose the command line in quotes and use the /S switch as > well.. > > From a dos prompt, try cmd /? for more details on the switches for the cmd > executable. > > I'd be interested in hearing the results of your experiments. > > -- > ROGER NEYMAN > > "Tomer Ben-David" <> wrote in message > news: om... > > (Tomer Ben-David) wrote in message > news:<. com>... > > > Hi > > > > > > Is there any way to open the dos command prompt from java (this black > > > dos window...) > > > I want to execute some dos command and to execute them using java code > > > that will run them inside that black dos window... > > > > > > I know I can use... > > > Runtime.getRuntime().exec("run.bat", null); > > > and get a handle to its inputStream however this is not what I want > > > since I want to open that run.bat in the dos prompt ... > > > > its ok I found the solution > > > > Runtime.getRuntime().exec("cmd /c start run.bat"); > > > > > > > > However Now im facing another problem, anyone knows how can I redirect > > the output of the dos prompt to a file AND as well that it stays in > > the DOS prompt black screen? > > > > Thanks |
|
|
|
#8 |
|
Posts: n/a
|
"rpnman" <> wrote in message news > from the command line use redirection ">" as in > >Dir *.java>javaFiles.txt > > I suspect, but I do not know, that you'll be able to include this in command > lines passed to .getRuntime().exec() as well. > > You may need to enclose the command line in quotes and use the /S switch as > well.. > > From a dos prompt, try cmd /? for more details on the switches for the cmd > executable. > > I'd be interested in hearing the results of your experiments. NAME tee -- clone output stream SYNOPSIS tee [-ai] [file...] DESCRIPTION The tee command clones an output stream. It copies each output file as well as to the standard output. > -- > ROGER NEYMAN > > "Tomer Ben-David" <> wrote in message > news: om... > > (Tomer Ben-David) wrote in message > news:<. com>... > > > Hi > > > > > > Is there any way to open the dos command prompt from java (this black > > > dos window...) > > > I want to execute some dos command and to execute them using java code > > > that will run them inside that black dos window... > > > > > > I know I can use... > > > Runtime.getRuntime().exec("run.bat", null); > > > and get a handle to its inputStream however this is not what I want > > > since I want to open that run.bat in the dos prompt ... > > > > its ok I found the solution > > > > Runtime.getRuntime().exec("cmd /c start run.bat"); > > > > > > > > However Now im facing another problem, anyone knows how can I redirect > > the output of the dos prompt to a file AND as well that it stays in > > the DOS prompt black screen? > > > > Thanks > > |
|
|
|
#9 |
|
Posts: n/a
|
On 18 May 2004 10:35:29 -0700, (Tomer
Ben-David) wrote or quoted : >I found your articles very interesting and very clear! and i looked at >the exec utility that simplifies things, and read about the >inputstream issue with the process however, I dindnt find any clue >whether its possible to direct the output BOTH to a file AND to the >console! Im currently going to use, java service wrapper it kind of >performing it, it might interest you as well... see http://mindprod.com/jgloss/tee.html -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary. |
|