Created
July 5, 2012 19:22
-
-
Save clayalvord/3055865 to your computer and use it in GitHub Desktop.
Ruby script for getting system info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@user = `whoami` | |
@system = `scutil --get ComputerName` | |
@ip = (`ifconfig en0 | grep netmask`).split | |
@vers = (`sw_vers | grep ProductVersion`).split | |
@hw_info = `system_profiler` | |
@up = (`uptime`).split(',') | |
if @vers[1].include?('10.5') | |
@hw_name = 'Processor Name' | |
@hw_speed = 'Processor Speed' | |
else | |
@hw_name = 'CPU Type' | |
@hw_speed = 'CPU Speed' | |
end | |
puts "User: #{@user}" | |
puts "Computer: #{@system}" | |
puts "IP: #{@ip[1]}" | |
puts "OS Version: #{@vers[1]}" | |
puts @hw_info.grep(/#{@hw_name}/).to_s.strip | |
puts @hw_info.grep(/#{@hw_speed}/)[0].to_s.strip | |
puts @hw_info.grep(/Memory:/)[0].to_s.strip | |
puts "Uptime: #{@up[0].strip}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment