Jump to content

Force Windows CMD to see > in quoted parameter as >


 Share

Recommended Posts

Hello everyone

I'm writing a script that executes a command line RunWait function, and part of the command line is a parameter that contains ">" (quoted). If I type this command into the Windows CMD window manually, the command executes correctly, interpreting the quoted ">" as simply a parameter, but if I run it via AutoIt, then Windows interprets the ">" as a literal ">", despite the quotes.

In other words, if I type this java.exe -jar PROGRAM.jar INPUTFILE.html OUTPUTFILE.tmx "0>EN-US,1>PT-BR" manually into the Windows CMD window, then it works as expected (it creates an output file named OUTPUTFILE.tmx). But if I use AutoIt's RunWait, it doesn't create OUTPUTFILE.tmx, but instead creates EN-US and PT-BR. If used via AutoIt, Windows treats "0>EN-US,1>PT-BR" (quoted) as 0>EN-US,1>PT-BR (unquoted).

The line in the script is this:

RunWait(@ComSpec & " /c " & '"' & $javapath & '" -jar HTML2TMX.jar "' & $htmlfile & '" "' & $tmxfile & '" "0>' & $lcodeSL & ',1>' & $lcodeTL & '"')
Without resorting to the creation of an external BAT file to take care of this command, how can I get AutoIt to send the command to Windows CMD correctly?

Thanks

Samuel

Added:

The full files that I'm using are here:

http://wikisend.com/download/341218/AU3%20HTML2TMX.zip

Edited by leuce
Link to comment
Share on other sites

What is the result for this ?

RunWait(@ComSpec & " /k echo " & '"' & $javapath & '" -jar HTML2TMX.jar "' & $htmlfile & '" "' & $tmxfile & '" "0>' & $lcodeSL & ',1>' & $lcodeTL & '"')
Link to comment
Share on other sites

You should build your string and the examine it to be sure it had the quotes in the correct place.

I'm quite confident about that, but I'm open to suggestions.

 

P.S. Try this:

RunWait(@ComSpec & " /c " & '"' & $javapath & '" -jar HTML2TMX.jar "' & $htmlfile & ' ' & $tmxfile & ' "0>' & $lcodeSL & ',1>' & $lcodeTL & '"')

That has no effect, even if I use this (which is what I think you meant):

RunWait(@ComSpec & " /c " & '"' & $javapath & '" -jar HTML2TMX.jar ' & $htmlfile & ' ' & $tmxfile & ' "0>' & $lcodeSL & ',1>' & $lcodeTL & '"')

I tried it, but I knew what would happen, because $htmlfile is a path name with (potentially) spaces in it. Perhaps I should have made that clearer. The only file that is located in the same path as the script is HTML2TMX.jar. So these paths have to be enclosed in quotes.

Edited by leuce
Link to comment
Share on other sites

What is the result for this?

RunWait(@ComSpec & " /k echo " & '"' & $javapath & '" -jar HTML2TMX.jar "' & $htmlfile & '" "' & $tmxfile & '" "0>' & $lcodeSL & ',1>' & $lcodeTL & '"')

This:

"C:Program Files (x86)OmegaTjrebinjava.exe" -jar HTML2TMX.jar "C:UsersmynameDesktopAU3HTML2TMXBook1.html" "C:UsersmynameDesktopAU3HTML2TMXBook1.html_en-ZA_af-ZA.tmx" "0>en-ZA,1>af-ZA"

...which is exactly right.

I also tried fiddling with my anti-virus, but even if I disable it, I get this problem.

Link to comment
Share on other sites

Can you maybe write this into a more specific reproducer? Because I tried this java code:

class Test {
    public static void main(String[] args) {
        for (String arg : args) {
            System.out.println(arg);
        }
    }
}

... which I then executed through this AutoIt code:

RunWait(@ComSpec & ' /k java -cp "d:\tmp" Test "1" "2" "1>2,3>4"')

... which then produces:

1
2
1>2,3>4

... which looks fine :)

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Can you maybe write this into a more specific reproducer? Because I tried this java code...

If by "reproducer" you mean that I should edit the Java program, then I'm afraid I can't do that. Yes, it's GPL, but I can't do Java :-( Yes, I suspected the problem might lie with the Java program, as from what I've read in other forums the way Windows treat parameters may depend on the program being run.

Anyway, I "solved" the problem by making the script create a temporary .bat file with the command in it, and then tell the script to run that .bat file, and then delete the temporary .bat file afterwards. It's not ideal... but it works.

Link to comment
Share on other sites

Ah, right... Well, I guess you could compile my test class and try your code on it, but if this works for you, then fine :) Maybe you could change your code to store your entire commandline in a variable and log that before executing it, so you're absolutely sure there's no unescaped quotes.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...