Not to revive this old thread, but I figure this is a good place to keep all these for the time being, so heres a new one.
This script will use Nmap to determine all hosts which are currently connected to the network you are on. Before this script can be used you must have nmap, apcalc, and dog installed. (Yes...dog. It's kinda like cat v2.0)
Code:
#!/bin/sh
#
# Script by Jason Gotti (email removed for spambots)
# Written and tested on Ubuntu 7.04.
#
# Developed for use with conky, but also can be used
# for other information related purposes.
#
# Variables. Change "ath0" to reflect your network interface. (Check in "ifconfig")
# You also need to install nmap, apcalc, and dog for this script to function correctly..
addressrange=$(ifconfig ath0 | grep "inet addr" | awk -F: {' print $2 '} | awk {' print $1 '} | awk -F. '{ print $1,".",$2,".",$3,".",0,"/24" }' | tr -d " ")
numberofhosts=$(nmap -sP $addressrange | grep Host | wc -l)
currenthost=1
host=$(nmap -sP $addressrange | grep Host | dog -l $currenthost | awk '{ print $2 }')
while [ $currenthost -le $numberofhosts ]
do
echo $host
currenthost=$(calc $currenthost+1)
host=$(nmap -sP $addressrange | grep Host | dog -l $currenthost | awk '{ print $2 }')
done
It's callled in conkyrc like so:
Code:
${color #ffcb48}Disk Usage Info:
${color #FFFFFF}${execi 5 diskfreeinfo}
And finally, it outputs like this on my current network. Of course, it's going to change to display the hosts on your network.
Code:
Hosts Online:
192.168.2.1
192.168.2.20
192.168.2.104
Enjoy!
Bookmarks