exec {
'oracle-extract-part':
command => "/usr/bin/printf
\"n\np\n2\n2091\n+16384M\nw\n\" | /sbin/fdisk /dev/xvdj",
unless => "/bin/cat /proc/partitions | /bin/grep
${orcl_ephm_device}2";
}
With three \, it ends up looking like this in the log:
Nov 21 01:27:45 dev-c3-app-15 puppet-agent[3091]:
(/Stage[main]/Oracle::Server11g/Exec[oracle-swap-part]/returns) change
from notrun to 0 failed: /usr/bin/printf
\"n\#012p\#0121\#0121\#012+32768M\#012t\#01282\#012w\#012\" |
/sbin/fdisk /dev/xvdj returned 1 instead of one of [0] at
/etc/puppet/devmp/modules/oracle/manifests/server11g.pp:136
Now... that's obviously not right. How do I escape \ symbols?
Doug.
if you don't need to interpolate a variable, you can simply use single
quotes, so you don't need to escape anything.
grrr ~pete
Sounds like you need to use FOUR. Say you wanted to use printf to print
a newline. You would run this:
(1) printf \n
But, the backslash has special meaning in bash (or most shells). If you
type that in bash, you have to escape it, one of these ways:
(2) printf \\n
(3) printf '\n'
Puppet runs commands through a shell. So, you will have to apply
escaping appropriate for whatever shell is in use.
But, the command is also in a string. Backslashes have special meaning
in puppet strings. So, we know the command we want to give to bash is:
(4) printf \\n
To put that in a puppet string we need to escape the \:
(5) "printf \\\\n"
If you don't like all the backslashes, you could give single quotes to bash:
(6) "printf '\\n'"
This is example 3, quoted with puppet's rules. You could also use single
quotes in Puppet, but Puppet's single-quote strings still find special
meaning in \, so it doesn't really get you anything, and if you are
using single quotes for bash it's actually worse. You'd need this:
(7) 'printf \'\\n\''
Given (7), puppet will give (8) to bash:
(8) printf '\n'
and bash will give to exec():
(9) printf \n
Make sense?
%q{string string string}
Max
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
> How about using the alternate single quotes in ruby
>
> %q{string string string}
puppet manifests are not ruby code.
~pete