aspose file tools*
The moose likes Java in General and the fly likes Runtime.exec problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Runtime.exec problems" Watch "Runtime.exec problems" New topic
Author

Runtime.exec problems

CSLA Sanchez
Greenhorn

Joined: Feb 07, 2004
Posts: 5
Dear Developers,
Hope you can help with the following:
I can successfully get the "dir" contents in the same way I do at the DOS prompt by doing the following:
Runtime runtime = Runtime.getRuntime();

Process proc = runtime.exec("cmd /c dir");
I can also run a perl script via:
Process proc = runtime.exec("cmd /c perl MyPerl.pl");
HOWEVER, the command I need to run is "ss.exe" which is part of VisualSource Safe. At the command prompt, I use this command with the "dir" argument to get a directory listing of the current Visual SourceSafe Database as follows:
c:\temp>ss dir
and I get the results in here.
For some reason, this does not work in Java:
Process proc = runtime.exec("cmd /c ss dir");
I do not get an exception by doing this, and I tried to redirect the output to a file by:
Process proc = runtime.exec("cmd /c ss dir > out.txt");
The file "out.txt" gets created, but it is empty!!
How could I invoke Visual Source Safe command line arguments via Runtime.exe??
Thanks!
--Cecilia.
Lu Battist
Ranch Hand

Joined: Feb 17, 2003
Posts: 104
I've always had better luck running a .bat file than the actual command. I suspect the problem is that 'ss.exe' is not a recognized command to the process that runs it. It works from dos because you have path variables set. When you try it again type the full path to the executable whether you use a .bat file or not this may help.
Also, if you don't wait for it to finish before closing things this could be a problem as well.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I agree with all Lu's points. Additionally, there may be an error message being generated but not read. Process has a getError() method which allows you to read this. It's often easier to redirect the error output to a file, much like you've done for standard output:

Or send everything to the same file:


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime.exec problems