Very useful info Ken - those are the couple of things I was actually
looking for. It'll certainly get me going.
One more thing, how do I do "if..else.." thing in there? Like:

if [ "$n1" == "$n2" ]; then
    echo "something here"
elif [  "$n2" == "$(($n1*2))" ]; then
    echo "something else here...."
.....
.....
fi

Cheers!!

On Jun 14, 1:42 pm, Ken Barber <k...@puppetlabs.com> wrote:
> Not pretty - but hacking up your example to work in ruby should be
> something like:
>
> Facter.add("num_core") do
>   setcode do
>     dd_code=`which dmidecode`.chomp
>     n1=`#{dd_code} -t processor | grep -c "Socket Designation"`.chomp.to_i
>     n2=`#{dd_code} -t processor | grep "Core Count" | uniq | awk
> '{print $3}'`.chomp.to_i
>     n1*n2
>   end
> end
>
> The key things here are the chomps to remove newlines, the #{} format
> for variable interpolation in strings and the to_i to get integers.
> Also not the n1*n2 at the end - this will return the result (no need
> for return unless you want it).
>
> ken.

-- 
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.

Reply via email to