Pupppet syslog "unrecognised escape sequence" in string

43 views
Skip to first unread message

Andreas Dvorak

unread,
Feb 4, 2014, 11:15:26 AM2/4/14
to puppet...@googlegroups.com
Dear all,

I have several exec resources that work fine, but the puppet master throws a syslog message

"Unrecognised escape sequence \# in file /data/git/simulation/modules/base_modification/manifests/only_solaris.pp at line 14"

14: exec{ "/bin/sed '\#^/home#d' /etc/auto_master > /tmp/sed.tmp.$$ && mv /tmp/sed.tmp.$$ /etc/auto_master":
15:        onlyif => "/bin/grep '^/home' /etc/auto_master"
16:      }

I do not want to filter that mesage, but how can tell puppet this is fine or do I need to change the exec resource.

Regards
Andreas

David Schmitt

unread,
Feb 4, 2014, 12:28:26 PM2/4/14
to puppet...@googlegroups.com
puppet is telling you that it is trying to interpret the backslash-hash
(\#) sequence in the string, but has not found a useful interpretation.
I guess that you'd like to ACTUALLY have a backslash and a has in the
string, in which case you'll need to put backslash-backslash-hash (\\#)
in there as long as you're using double quotes (").

Read more about this in the Language Reference:

> http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#strings



Regards, David
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/df83f496-54cb-4c65-9382-dd907c0393d9%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Jason Antman

unread,
Feb 4, 2014, 12:30:14 PM2/4/14
to puppet...@googlegroups.com
Your exec resource has a double-quoted string.

1) You're not doing variable interpolation, so that should be a
single-quoted string (per the accepted style).
2) Puppet *happens* to allow "\#". The docs on Puppet string types and
escaping
(https://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#double-quoted-strings)
clearly list the allowed escape sequences. As \# isn't one of them, you
should be doubling the leading "\" to escape it.

If you do keep that as a double-quoted string, you need to escape $ as well.

-Jason

Andreas Dvorak

unread,
Feb 4, 2014, 1:19:52 PM2/4/14
to puppet...@googlegroups.com
Hi,

thank you I think I do understand it.
Here is my solution
exec{ '/bin/sed \'\#^/home#d\' /etc/auto_master > /tmp/sed.tmp.$$ && mv /tmp/sed.tmp.$$ /etc/auto_master'
and it works

Best regards,
Andreas
Reply all
Reply to author
Forward
0 new messages