Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #from http://unix.stackexchange.com/questions/74699/get-network-information-through-ubuntu-terminal
- if ! /bin/ip route | grep -q ^default; then
- echo "No Internet connection"
- echo
- exit 0
- fi
- if="$(/bin/ip route |
- awk '$1 == "default" {for (i=2;i<=NF;i++) if ($i == "dev") { i++;print $i; exit}}')"
- if [ -z "$if" -o \! -e /sys/class/net/"$if" ]; then
- echo "Sorry, some error, aborting."
- echo
- exit 1
- fi
- if /usr/sbin/iw dev "$if" info &>/dev/null; then
- echo "The Internet connection is wireless."
- echo
- # uncomment the next line to start iwconfig
- # iwconfig
- else
- echo "The Internet connection is wired."
- echo
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement