shell module and escaping special characters

1,707 views
Skip to first unread message

Jim McMahon

unread,
Mar 4, 2015, 5:17:34 PM3/4/15
to ansible...@googlegroups.com
The shell module seems to escape special characters like \ and ".   Is there a way so that the shell module doesn't escape these characters? Are there any tips on how handle situations where you want double quotes?

Joanna Delaporte

unread,
Mar 4, 2015, 8:27:23 PM3/4/15
to ansible...@googlegroups.com
I use shell a fair amount and have occasionally run into some similar issues. I sometimes wrap the entire shell command in single or double quotes, if it contains a special character. An example:

- name: determine firefox version
  shell: "firefox -v | cut -d ' ' -f3"
  register: ffversion


I also used double quotes with sed commands in the past, but lineinfile works just as well. However, I sometimes have to play with the quote placement for a while to make lineinfile work.

Joanna

Jim McMahon

unread,
Mar 4, 2015, 11:11:04 PM3/4/15
to ansible...@googlegroups.com
Thanks Joanna. 

I think I’ve solved my particular issue by making heavy use of templates where I can put the double quotes and backslashes where I need them, then use the dest file as input to a command (e.g., mysql < my template.sql)

Jim


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/IN32_h4gwBE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8c78206c-85aa-4279-9227-f2380b12f9d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages