Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save pgharios/a368d7cb8487f7346e7ebee6d787682b to your computer and use it in GitHub Desktop.

Select an option

Save pgharios/a368d7cb8487f7346e7ebee6d787682b to your computer and use it in GitHub Desktop.
threads = []
253.times {
|ip|
threads << Thread.new {
ipCommand = `ping -c 1 10.11.1.#{ip+1}`
$stdout.puts #{ipCommand}
}
}
threads.each { |aThread| aThread.join }
@pgharios
Copy link
Copy Markdown
Author

threads = []
253.times {
|ip|
threads << Thread.new {
ipCommand = ping -c 1 10.11.1."#{ip+1}" | grep "bytes from" | cut -d" " -f 4 | cut -d":" -f 1
Thread.exit if ipCommand == ""
puts ipCommand
}
}

threads.each { |threadA| threadA.join }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment