Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 6th, 2010 | Syntax: None | Size: 1.04 KB | Hits: 110 | Expires: Never
Copy text to clipboard
  1. #!/bin/bash
  2.  
  3. #####################
  4. # Settings
  5. #####################
  6.  
  7. ### regexp for IP search (first octect of IP addresses should be sufficient) ###
  8. ### to search multiple subnets use the infix operator |  such as:
  9. #IPSEARCH="147|64"
  10. #IPSEARCH="190|200";
  11. #IPv6 use the first few digits like so...
  12. IPSEARCH="2001:470:";
  13.  
  14. ### colors ###
  15. #title color
  16. COL1="\x1b[0;31;40m";
  17. #ip color
  18. COL2="\x1b[0;32;40m";
  19. #'=' color
  20. COL3="\x1b[0;34;40m";
  21. #domain color
  22. COL4="\x1b[0;33;40m";
  23. #error color
  24. COL5="\x1b[0;31;40m";
  25. #colors off (back to natural terminal colors)
  26. COLOFF="\x1b[0;37;00m";
  27.  
  28. ### footer (Displayed at end of list) ###
  29. FOOTER="Enjoy!"
  30.  
  31. ### Command paths ###
  32. IFCONFIG="/sbin/ifconfig";
  33. GREP="/bin/grep";
  34. AWK="/usr/bin/awk";
  35. HOST="/usr/bin/host";
  36.  
  37. ##################
  38. #Code goes here
  39. ##################
  40.  
  41. HOSTNAME=`hostname`;
  42. echo -en "$COL1 Hostnames for $HOSTNAME\n";
  43. for tip in `$IFCONFIG | $GREP inet | $AWK '{print $2}' | $GREP -E "$IPSEARCH"`;
  44. do
  45.   IFS=":"
  46.   zip=($tip);
  47.   ip=${zip[1]};
  48.   echo -ne "$COL2$ip $COL3=";