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

Working around Local Command automatic escaping #395

Closed
kcd83 opened this issue May 12, 2013 · 1 comment
Closed

Working around Local Command automatic escaping #395

kcd83 opened this issue May 12, 2013 · 1 comment
Labels
Milestone

Comments

@kcd83
Copy link

kcd83 commented May 12, 2013

I've found some variations in the escaping, specifically my problem is I cannot get spaces or quotes into local commands because of what appears to be automatic escaping.

  • This is a correctly escaped curl command that works in Commands/Scripts:
curl -w Response:%{http_code}\&extrachars\?\\n -s "http://www.google.com/"
  • By removing the required escaping I can get this LocalCommand to work:
curl -w Response:%{http_code}&extrachars?\\\n -s http://www.google.com/
  • However I want a local command requiring various characters because of the url
curl "http://${node.hostname$}/someurl?parameter1=1&parameter2=A%20Parameter"

I cannot work out quotes or spaces, everything I do produces errors. Here are some curly test cases... I appologise in advance that they are not the best examples.

Test 1

curl -k -s --output /dev/null -w Response:%{http_code} & extrachars ?\n -s http://www.google.com/

Command:

     localhost12-NodeDispatch-exec  
10:17:18    Response:302 & extrachars ?

Script:

     localhost13-NodeDispatch-script    
  10:17:18  Response:302 & extrachars ?

Local command:

     localhost14-NodeDispatch-localexec 
10:17:18    Failed: NonZeroResultCode: Result code was 1

Test 2 - Without sending the content to dev/null

curl -k -w Response:%{http_code}\ \&\ extrachars\ \?\\n -s http://www.google.com/

Command:

10:09:05    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
10:09:05    <TITLE>302 Moved</TITLE></HEAD><BODY>
10:09:05    <H1>302 Moved</H1>
10:09:05    The document has moved
10:09:05    <A HREF="http://www.google.co.nz/">here</A>.
10:09:05    </BODY></HTML>
10:09:05    Response:302 & extrachars ?

Script:

10:09:05    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
10:09:05    <TITLE>302 Moved</TITLE></HEAD><BODY>
10:09:05    <H1>302 Moved</H1>
10:09:05    The document has moved
10:09:05    <A HREF="http://www.google.co.nz/">here</A>.
10:09:05    </BODY></HTML>
10:09:05    Response:302 & extrachars ?

Local command:

10:09:06    Response:000\Response:000\Response:000\<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
10:09:06    <TITLE>302 Moved</TITLE></HEAD><BODY>
10:09:06    <H1>302 Moved</H1>
10:09:06    The document has moved
10:09:06    <A HREF="http://www.google.co.nz/">here</A>.
10:09:06    </BODY></HTML>


@gschueler
Copy link
Member

Testing this in the 1.6.1-snapshot. there were changes in the way things are quoted/escaped recently (1.5.x timeframe).

Note the varying contexts for the ways these steps operate.

  1. Command: interpreted by Rundeck, variables expanded, tokens re-quoted if necessary, passed to Ant Exec task
  2. Script: tokens expanded by Rundeck but no quoting interpreted, passed to shell
  3. Local command: variables expanded, passed to Local Command plugin, executes in shell.

FWIW, I was able to get what I think you were trying to get working in 1.6.1-snapshot, see attached screenshot.

screen shot 2013-08-23 at 2 31 59 pm

the Command step needs to be double-quoted. First to be treated as a single token by Rundeck, secondly because unless a Rundeck context variable is expanded in the within a token, the token is passed as-is to the shell to be interpreted, and since you want the shell to have quotes around the space characters we need a second set of quotes.

I'd like the Command step to not use the Ant Exec task eventually, it would then operate more like the Local Command plugin.

FYI: Quoting rules for rundeck commands

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

No branches or pull requests

2 participants