Hi, Thanks a lot guys I got it working Yes I had to run an concurrent thread and draing the stdout/err I found an very helpful article on net which can be useful to other facing the same problem
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=3 On Aug 13, 9:37 am, jhulford <[email protected]> wrote: > Also, use ProcessBuilder. You haven't really said what DOS command > you're trying to run but here's what you'd do to quietly delete (ie. > no prompts) all the files in some test directory. > > ProcessBuilder b = new ProcessBuilder("cmd", "/C", "del", "/Q", "\\some > \\test\\directory"); > //sets the working directory of the process - don't NEED to do this if > your command points to a full path > //If you don't set this, the CWD will be the same as "user.dir" system > property > b.directory("\\some\\dir"); > //pipe stderr into stdout (useful if you just need to drain the output > of the command and don't care > //if the data is error or info data) > b.redirectErrorStream(true); > Process p = b.start(); > //wait for the command to finish executing > p.waitFor(); > //0 is the standard for "normal" execution exit value (depends on the > actual executable though) > int exitStatus = p.exitValue(); > > Additionally, if the command you're running has the potential to spit > out lots of output, you'll probably what to run a concurrent thread > and drain the process's stdout/err because all that data sits in a > buffer until you read it. So if it's a lot of data it could cause > memory problems for you. > > On Aug 12, 12:11 pm, Paul Robinson <[email protected]> wrote: > > > call Process.waitFor() -- this blocks until the process finishes > > > and then try looking at the output after calling waitFor() > > > Rahul wrote: > > > -lothar > > > I did that, there is no debugout neither a new directory is made when > > > i execute from gwt. If i execute it manually from the dos prompt I am > > > getting the desired output. > > > > -Paul > > > I tired calling your way also, nothing happens when im running a bat > > > file,no ouput is generated. but when i tired opening the notepad it > > > opens. There is no output in Process.getErrorStream() > > > > I believe that as lothar said, the Finalizer is killing my batch so > > > fast that it never gets executed > > > so how can i slow down the finalizer that my batch executes? > > > > On Aug 12, 11:59 am, Paul Robinson <[email protected]> wrote: > > > >> It may be that some useful output is going to the process's standard > > >> output or standard error. You can get at that by calling > > >> Process.getInputStream() andProcess.getErrorStream() > > > >> Rahul wrote: > > > >>> Hi, > > >>> Thanks a lot for your replies > > > >>> -lothar, its not leading to an IO exception, I checked it > > >>> - paul, i could not follow what you were trying to say > > > >>> when changed to cmd to notepad, the notepad opens > > > >>> when I read more about the exec command it says that it does not open > > >>> the command prompt(the black window), but it still executes the batch > > >>> job > > >>> so i am using the string : > > >>> try { > > >>> Runtime.getRuntime().exec("cmd.exe /C start > > >>> test.bat"); > > >>> } catch (IOException e) { > > >>> // TODO Auto-generated catch block > > >>> e.printStackTrace(); > > >>> } > > > >>> test.bat makes a hello directory in the specified location, but its > > >>> not working from this code. > > >>> if recognizes that its executint test.bat but theres no output > > > >>> when im runnning test.bat from dos prompt the desired output is > > >>> obtained but not from this > > > >>> On Aug 12, 11:15 am, Paul Robinson <[email protected]> wrote: > > > >>>> Try: > > > >>>> Process p = Runtime.getRuntime().exec("cmd.exe"); > > >>>> InputStream is = p.getInputStream(); > > > >>>> and then look at what you can read from the input stream > > > >>>> Rahul wrote: > > > >>>>> Hi, > > >>>>> I want to execute dos commands from gwt. Reading from this forum I > > >>>>> have to invoke the call from server not from the client. > > >>>>> This is my server side code: > > > >>>>> public String greetServer() > > >>>>> { > > >>>>> try { > > >>>>> Runtime.getRuntime().exec("cmd.exe"); > > >>>>> } catch (IOException e) { > > >>>>> // TODO Auto-generated catch block > > >>>>> e.printStackTrace(); > > >>>>> } > > >>>>> return "Hello"; > > > >>>>> } > > > >>>>> I am getting success at the client side that it was executed properly, > > >>>>> but I have one question: should the dos prompt window open when i > > >>>>> execute this program?? i tired putting cmd,cmd.exe but still the dos > > >>>>> prompt doesnt open > > >>>>> can anyone tell me what should i do ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
