Now that the configuration was correct, my task was to configure many (62 to be precise) printers on my Print Server. A few printers were in a different network. So, the task was to first ping them & determine their location. Doing it manually would have been a pain (pinging 62 devices) 😦 So I chose to write a script to help me achieve it 😉
Below is that script.
while read line do ping_response=`ping -c1 $line|grep PING|cut -d"(" -f2|cut -d")" -f1 2>/dev/null` ipAddressFirstOctet=`echo "$ping_response"|cut -d"." -f1` re='^[0-9]+$' //Any output other than ping response. Happens when ping doesn't find that host. if [[ $ipAddressFirstOctet =~ $re ]] then if [ "$ipAddressFirstOctet" -eq 10 ] //10 is first octet for our DMZ then echo "$line ($ping_response) is TCS Printer" else echo "$line ($ping_response) is CSC Printer" fi fi done<~shashank/printer_list