Combreal

getMacAddr.sh

Feb 25th, 2021 (edited)
402
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ifconfig > /tmp/ifconfig_nodongle
  4.  
  5. while true; do
  6.     read -p "Have you plugged in the ethernet dongle?" yn
  7.     case $yn in
  8.         [Yy]* ) ifconfig > /tmp/ifconfig_dongle; break;;
  9.         [Nn]* ) exit;;
  10.         * ) echo "Please answer yes or no.";;
  11.     esac
  12. done
  13.  
  14. diff /tmp/ifconfig_nodongle /tmp/ifconfig_dongle | grep ether | awk '{print $3}'
  15. rm -rf /tmp/ifconfig_nodongle /tmp/ifconfig_dongle
RAW Paste Data