class RBT::StaticOverviewOfTheAvailableBinariesOnThisComputerSystem
Public Class Methods
[](i = ARGV)
click to toggle source
new( commandline_arguments = nil, run_already = true )
click to toggle source
Public Instance Methods
report_how_many_statically_compiled_programs_were_encountered()
click to toggle source
#¶ ↑
report_how_many_statically_compiled_programs_were_encountered
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/static_overview_of_the_available_binaries_on_this_computer_system.rb, line 143 def report_how_many_statically_compiled_programs_were_encountered e "#{sfancy(@encountered_n_statically_compiled_programs.to_s)} "\ "#{rev}statically compiled programs were discovered on "\ "this computer system." end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/static_overview_of_the_available_binaries_on_this_computer_system.rb, line 42 def reset super() infer_the_namespace # ======================================================================= # # === @encountered_n_statically_compiled_programs # ======================================================================= # @encountered_n_statically_compiled_programs = 0 # ======================================================================= # # === @array_work_on_these_directories # ======================================================================= # @array_work_on_these_directories = %w( /usr/bin/ /bin/ ) end
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/static_overview_of_the_available_binaries_on_this_computer_system.rb, line 61 def run opnn { :no_trailing } e e e 'Showing an overview of all static binaries on this system (at the '\ 'least in '+sdir('/usr/bin/') e "#{rev}and #{sdir('/bin/')}#{rev}) next:" e @array_work_on_these_directories.each {|this_directory| Dir["#{this_directory}*"].sort_by {|entry| entry.downcase }.each {|this_file| if File.directory? this_file e "#{rev}Note that #{sdir(this_file)} #{rev}is a directory." if is_on_roebe? # I can remove this. \o/ e 'This is questionable: check on this perhaps before '\ 'continuing here.' exit end end # =================================================================== # # We will exclude files that are e. g. perl files such as .pl # or .py. # =================================================================== # next if this_file.include? '.' next if File.empty?(this_file) # Ignore empty files. # =================================================================== # # We can not ignore symlinks because of stuff like this: # # /usr/bin/ls -> /home/Programs/Coreutils/8.31/bin/ls # # next if File.symlink?(this_file) # =================================================================== # # =================================================================== # # If the first line includes '#!/' then we will assume this to # be a "scripting" file. # =================================================================== # is_it_a_scripting_file = false begin if File.exist?(this_file) File.open(this_file) {|file| first_line = file.readline if first_line.include?('#!/') or # Assume this to be a "scripting" file. first_line.start_with?('#!') is_it_a_scripting_file = true end } end rescue EOFError => error e orange('Problem with ')+sfile(this_file) pp error pp error.class end next if is_it_a_scripting_file # =================================================================== # # Next we will run "ldd" on the binary at hand. # =================================================================== # cmd_to_use = "ldd #{this_file}" # e tomato(cmd_to_use)+': ' result = `#{cmd_to_use}` if result.include?('not a dynamic executable') raw_name = File.basename(this_file) result = "#{rev} #{steelblue(this_file.ljust(35))} #{rev}is "\ "most likely a #{olivedrab('static executable')}." hash_all_binaries = RBT.all_binaries? if hash_all_binaries.include?(raw_name) result = result.dup if result.frozen? result << " #{rev}It belongs to the program called "\ "#{lightgreen(hash_all_binaries[raw_name])}." end e result @encountered_n_statically_compiled_programs += 1 end } } e report_how_many_statically_compiled_programs_were_encountered e end