Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping Switch Delimiter Used in Arguments #18

Open
nariman-haghighi opened this issue May 3, 2013 · 5 comments
Open

Escaping Switch Delimiter Used in Arguments #18

nariman-haghighi opened this issue May 3, 2013 · 5 comments

Comments

@nariman-haghighi
Copy link

Trying to run a silent install of java through Bootstrapper which uses this package:

bootstrapper.exe /get role-setup/jre-7u9-windows-x64.exe /lr $lr(tempInstallationDir) /sc $config(ConnectionString) /run $lr(tempInstallationDir)\jre-7u9-windows-x64.exe /args /s /L "%RoleRoot%\approot\java-install.log" /block

http://java.com/en/download/help/silent_install.xml

But can't seem to escape the args value of (/s /L "%RoleRoot%\approot\java-install.log")

Any suggestions?

@cbrianball
Copy link
Member

I'm not sure what you mean by "escape". What value are you expecting from /L and what value are you actually getting when you use Args?

@nariman-haghighi
Copy link
Author

Expecting the java switches passed in via /args to not be interpreted, just
passed on in raw form.

@cbrianball
Copy link
Member

OK, so everything after /args needs to be one string value that you will then pass into another executable?

My first thought (without actually testing it myself) would be to have your command-line look like:
bootstrapper.exe .... /args "/s /L \"%RoleRoot%\approot\java-install.log\" /block"

I would expect that to cause your "args" property/field to then contain the value:
/s /L "%RoleRoot%\approot\java-install.log" /block

@nariman-haghighi
Copy link
Author

Didn't seem to work. Reverted back to '-' as the switch delimiter to overcome this, would make for a good test case.

@cbrianball
Copy link
Member

I think I see what the problem is, the first character in the literal is still "/". This would be a hack, but try:
bootstrapper.exe .... /args " /s /L \"%RoleRoot%\approot\java-install.log\" /block"

Note the space after the quote. Unfortunately I have no way of knowing that the "/s" was proceeded by a quote just by looking at string[] args. I could look at System.Environment.CommandLine and parse everything out manually, but then I'd need to know how the OS parses out the command line (escaping special characters and such) in order to duplicate that correctly, and at that point I feel like I am sort of just "reinventing the wheel".

I'm open to hearing arguments for additional reasons why it would be beneficial to write my own parser and not rely on the OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants