On 10/09/2014 03:46 PM, Spriya wrote:
> Hi,
>
> When i executed your facts. It is throwing me error
...
> *=> # @ldapname="java_versions1", @resolves=[], @searching=false, @value=nil>*
Uh, that's not an error. That's a fact if I ever saw one (well, I
didn't, but it's recognizable regardless ;-)
Hi,
When i executed your facts. It is throwing me error
*irb*
*irb(main):001:0> require 'facter'*
*=> true*
*irb(main):002:0> Facter.add(:java_versions1) do*
*irb(main):003:1* setcode do*
*irb(main):004:2* file = '/home/suppalapati/java.txt'*
*irb(main):005:2> if File.exists?('/home/suppalapati
Yea looks like the Facter readlines method doesn't exist.
http://ruby-doc.org/core-1.8.7/IO.html#method-c-readlines
You will need to use ruby's readlines and probably clean up the lines as
well with chop.
Revised edition: (untested, and probably full of syntax errors)
Facter.add(:java_version
Hi,
I used the same command which you provided me
Here is the code:
Facter.add(:java_versions1) do
setcode do
log = Facter::Util::FileRead.readlines(
'/home/suppalapati/java.txt')
if ! log.nil?
versions = log.collect {|command| `#{command}`}
else
*I would probably do something like this where we store all the java
versions in a comma separated string.Although if using facter >= 2.0 you
can probably remove the join statement and store as an array.I also want to
point out that java -version returns about 3 lines of text which may not be