Re: Runtime.exec on Win98: stdin, stdout with long DOS command line?



Bernard wrote:
Hi all Java Gurus

I can't get Runtime.exec() to work with DOS commands longer than 127
characters (the command.com limit) under Win98 2nd edition.

I use a workaround, start.exe to execute my DOS command. This executes
command lines successfully that are longer than 127 characters.

However, with start.exe, stdin and stdout of my executed command do
not appear to be accessible at all from the Java Process object.

Whatever I write to Process.getOutputStream() gets ignored, typically
with the effect of the DOS program hanging while it waits for input.

If I don't need to write to Process.getOutputStream(), then still
whatever I read from Process.getInputStream() is empty.

This is all Win9x specific, because on NT, Win2000 and XP systems,
there is no such command line length limitation, and therefore there
is no need for the start.exe workaround.

I use separate threads for reading stdin and stderr much like as
documented at
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html
so I am not a beginner in the use of Runtime.exec().

It appears to me that my issue is not yet documented anywhere on the
web. It would be nice to have a simple solution. As long as there is
none, my recommendation would be to avoid Runtime.exec on Win9*
platforms wherever stdin, stdout and stderr must be used, because it
would be dangerous to ignore the 127 character command line length
limit of command.com.

Any suggestions are highly appreciated.


1) You could try writing out your command to a temporary BAT file, and then simply execute the BAT file via Runtime.exec(). I think that the streams will be preserved in that case, but you may need to experiment.


2) Have you tried using Runtime.exec(String[]) (instead of Runtime.exec(String))?

HTH,
Ray

--
XML is the programmer's duct tape.
.



Relevant Pages

  • Re: Set App Priority
    ... string and then terminates" ... gives then parameters to use to modify the START command ... below) /F:OFF Disable file and directory name completion characters ... no special characters between the two quote characters, ...
    (microsoft.public.windowsxp.customize)
  • Re: Set App Priority
    ... This would start notepad with high priority. ... Starts a new instance of the Windows XP command interpreter ... /F:OFF Disable file and directory name completion characters ... If all of the following conditions are met, then quote characters ...
    (microsoft.public.windowsxp.customize)
  • Re: DOS Box Keyboard problem
    ... I get 437 from command chcp and cmd chcp. ... When in the cmd box I can type with all characters OK ... The OEMCP value controls to which OEM code page to translate ANSI, ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: Cannot delete file with name ended with a dot.
    ... receive the message "File Not Found" (from command prompt I cannot see the ... The operating system is Windows 2008 server standard x64. ... A little background on undeletable files and folders: ... files to it but use characters in the name that FTP supports (ASCII ...
    (microsoft.public.windows.server.general)
  • Re: [PATCH] USB: add USB test and measurement class driver - round 2
    ... accumulated (or until zero characters are returned, ... This logic should be done in userspace, ... a measurement command it is not known how many bytes it will return. ... handle this as a warning telling the user that he did not request all ...
    (Linux-Kernel)