Advertisement
Guest User

Untitled

a guest
Oct 26th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.50 KB | None | 0 0
  1. Facter.add("oraclesids") do
  2.   sids = []
  3.   filepath="/etc/oratab"
  4.   sid = nil
  5.   setcode do
  6.    if FileTest.file?(filepath)
  7.       begin
  8.         IO.readlines(filepath).each { |line|
  9.           next if line.include? "#"
  10.           next if line.include? "*"
  11.           line = line.lstrip
  12.           sid = line.split(':')
  13.           if ! sid.empty?
  14.             sids << sid[0]
  15.           end
  16.         }
  17.       rescue
  18.        sids = nil
  19.       end
  20.     end
  21.    sids.join(',')
  22.   end # end of proc
  23. end # end of add
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement