examples/jls.rb
changeset 7 4460fc10c6a3
equal deleted inserted replaced
6:2d52adc4adcc 7:4460fc10c6a3
       
     1 #!/usr/bin/env ruby
       
     2 #
       
     3 # An example of the 'jls' utility in ruby.
       
     4 # Output is sorted by hostname.
       
     5 #
       
     6 
       
     7 BEGIN {
       
     8         require 'pathname'
       
     9         basedir = Pathname.new( __FILE__ ).dirname.parent
       
    10 
       
    11         $LOAD_PATH.unshift basedir + "ext" unless 
       
    12                 $LOAD_PATH.include? basedir + "ext"
       
    13 }
       
    14 
       
    15 require 'jail'
       
    16 
       
    17 puts "   JID  IP Address      Hostname                      Path"
       
    18 BSD::Jail.sort_by {|j| j.host }.each do |j|
       
    19 	puts "%6d  %-15.15s %-29.29s %.74s" % [ j.jid, j.ip, j.host, j.path ]
       
    20 end
       
    21