> Do you know what am I doing wrong? How do I capture the system()
> output?
Try using %x{} instead of system. The system() function returns the
return code of the process, not the output.
Oh, and "chomp" the extra whitespace off the output. If you're new to
ruby, you can test ruby code in "irb", interactive ruby.
irb> %x{hostname --fqdn}.chomp
=> "dagon.fnord.no"
--
Stig Sandbeck Mathisen
Any sufficiently advanced incompetence
is indistinguishable from malice
Hi,
> Try using %x{} instead of system. The system() function returns the
> return code of the process, not the output.
> irb> %x{hostname --fqdn}.chomp
> => "dagon.fnord.no"
That worked, thanks!
For the record, this is how it looks like:
$new_ip=inline_template("<%= %x{host $hostname|awk '{print \$4}'}.chomp %>")
notify { "New IP: $new_ip": }
Kind regards,
Pablo