Skip to content

Instantly share code, notes, and snippets.

@Maniacal
Created June 27, 2012 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maniacal/3006472 to your computer and use it in GitHub Desktop.
Save Maniacal/3006472 to your computer and use it in GitHub Desktop.
Problem with awk command
This is what I have in my recipe:
bash "Set newrelic java options" do
user "root"
group "root"
cwd glassfishconfig
code <<-EOH
awk -v searchterm="<java-config" -v payload=" <jvm-options>-javaagent:#{newrelic_dir}/newrelic-#{node[:newrelic][:version]}/newrelic.jar</jvm-options>\n <jvm-options>-Dnewrelic.config.file=#{newrelic_dir}/#{node[:app][:key]}/newrelic.yml</jvm-options>\n <jvm-options>-Dnewrelic.config.log_file_path=#{newrelic_dir}/#{node[:app][:key]}/logs</jvm-options>" '{ if ($0 ~ searchterm) print $0 "\n" payload; else print $0 }' domain.xml.newrelic.bak > domain.xml
EOH
action :nothing
end
When that runs in the chef run I get this:
---- Begin output of "bash" "/tmp/chef-script20120627-8350-r7jiup" ----
STDOUT:
STDERR: awk: { if ($0 ~ searchterm) print $0 "
awk: ^ unterminated string
---- End output of "bash" "/tmp/chef-script20120627-8350-r7jiup" ----
But if I run that awk command from the command line it works fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment