Display current IP addresses (Ethernet & WiFi)


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #! /bin/bash
  2. myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
  3.  
  4. if [ "$myen0" != "" ]
  5. then
  6. echo "Ethernet : $myen0"
  7. else
  8. echo "Ethernet : INACTIVE"
  9. fi
  10.  
  11. myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
  12.  
  13. if [ "myen1" != "" ]
  14. then
  15. echo "AirPort : $myen1"
  16. else
  17. echo "Airport : INACTIVE"
  18. fi

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.