*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
desirable. I am also not sure if Facter has a readlines method (guessing
it does), so you might have to swap out with ruby's file reading code.*
Facter.add(:java_versions) do
setcode do
log = Facter::Util::FileRead.readlines( '/home/weblogic/java.txt')
* if ! log.nil? versions = log.collect {|command|
`#{command}`} else versions = `java -version`.to_a*
* end versions.join(",") end*
end
Corey
On Tuesday, October 7, 2014 10:31:12 AM UTC-7, Spriya wrote:
>
> Hi,
>
> I have a text file where i get all the java version.
>
> *cat java.txt*
> */usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/java -version*
> */usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java -version*
> */opt/oracle/agent12c/core/12.1.0.4.0/jdk/bin/java -version*
> */opt/oracle/agent12c/core/12.1.0.4.0/jdk/jre/bin/java -version*
> */var/lib/alternatives/java -version*
> */u01/java/jdk1.7.0_65/jre/bin/java -version*
> */u01/java/jdk1.7.0_65/bin/java -version*
>
>
> Now i want to run commands in each line and place it in facts.
>
> How can i do that.
>
> I have just started doing the code*.*
>
>
>
>
>
>
>
> *logfile = '/home/weblogic/java.txt'line_num=0log =
> Facter::Util::FileRead.read(logfile)unless log.nil? log.each_line do
> |line| output = Facter::Util::Resoloution.execHow can i can continue
> thatPlease help me*
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/05330e16-7286-42a6-a94c-b595c028659c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.