I have a project where I know a single computer and a single printer will be the only things on the network. What I want to do is detect when the printer is connected to the network. I also know that the computer is
192.168.3.1. However, with DHCP I won't know the printer address (yes, it could be made static to make it easier but, 'they' don't like that. 'They' want it dynamic)
What I have is a script that does the following and it works.
nmap -sP 192.168.3.0/24 \ | awk '/192.168.3/ && !/192.168.3.1$/' \ | sed 's/Nmap scan report for //'
Nmap scan report for 192.168.3.1 Host is up (0.014s latency). Nmap scan report for 192.168.3.100 Host is up (0.012s latency). Nmap done: 256 IP addresses (2 hosts up) scanned in 2.54 seconds
It only takes a couple seconds to work but is there a better/cleaner/faster way?