Re: java command line space & escape character parser for Runtime.exec



Hi Jimmy,

i.e. on the extreme side, here is a possible string (assuming user
always uses double slashes)
"\"C:\\My Test\\my test batch.bat" argA \"arg B\" \"arg\ C\" \"arg\tD\"
\"arg \/E\""

When you call Runtime.exec(), you don't need to have all the arguments
quoted.
Instead, use one of the forms of exec() that accepts a string array -
cmdarray - as the first argument. For example:

exec(String[] cmdarray)

The first string is the command and each string after that is a command
line argument. Of course, this assumes you have control over how the
input to your code gets formatted, so it might not help you...

Rob
:)

.



Relevant Pages

  • TIP #185: Null Handling
    ... nulls, and command modifications for manipulating them. ... Tcl deals with strings, the universal medium for representing data. ... is know and it is an empty string, but if a respondent forgets to give ...
    (comp.lang.tcl)
  • Re: Determine how Word was launched
    ... inspect the command line used to launch Word. ... Private Declare Function GetCommandLineA Lib "kernel32" As Long ... Public Function GetCommandLineAs String ... Dim lngCmdLinePtr As Long ...
    (microsoft.public.office.developer.vba)
  • Re: Class.getMethod in classs static initializer block
    ... I just wanted to add that I had some similar code for a "command line server" project. ... static private final boolean DEBUG = true; ... {public ReturnCode runCommand(String s) ... public ReturnCode parseLine(String line) ...
    (comp.lang.java.programmer)
  • Re: New "base document" available
    ... How to go about retrieving command line parameters? ... the command line arguments (and environment variables) ... Keyword and positional parameters can be mixed in the same command line. ... clp-name points to a string containing "P1" ...
    (comp.lang.cobol)
  • A plan for handling command line options
    ... Getopt is meant to be used by calling it once for each command ... In each case the first argument is an option string and the ... provide an error handling interface that the user can access. ...
    (comp.programming)