Skip to content

Instantly share code, notes, and snippets.

@clayalvord
Created July 5, 2012 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayalvord/3055865 to your computer and use it in GitHub Desktop.
Save clayalvord/3055865 to your computer and use it in GitHub Desktop.
Ruby script for getting system info
@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