blog advertising is good for you


blog advertising is good for you
User login

This is my very first post to any online blog. I am new to mac and scripting. I am really impressed with the Geektool considering the possibilities it has. I used the network script available on some blog but was not happy with the lengthy output so went through the script understanding wat was happening, then thought of creating my first script with trial and error method. This is my script:
================================================================
myen0=‘ifconfig en0 | grep “inet “ | grep -v 127.0.0.1 | awk ‘{print $2}’‘
myen1=‘ifconfig en1 | grep “inet “ | grep -v 127.0.0.1 | awk ‘{print $2}’‘
myvar1=‘system_profiler SPAirPortDataType | grep -e “Current Wireless Network:” | awk ‘{print $4}’‘
myvar2=‘system_profiler SPAirPortDataType | grep -e “Wireless Channel:” | awk ‘{print $3}’‘
router=‘netstat -rn | grep -e “default” | awk ‘{print $2}’‘
ext1=‘curl -s http://checkip.dyndns.org/ | sed ‘s/[a-zA-Z<>/ :]//g’‘
dns=‘cat /etc/resolv.conf | grep -e “nameserver” | awk ‘{print $2}’‘
isp1=‘whois -h whois.apnic.net $ext1 | grep -e “netname:” | awk ‘{print $2}’‘
if [ “$myen0” != “” ]
then if [ “$myen1” != “” ] then echo “Connection : Ethernet | Airport [$myvar1 : $myvar2]” echo “IP Address : $myen0 | $myen1” else echo “Connection : Ethernet” echo “IP Address : $myen0” fi
else if [ “$myen1” != “” ] then echo “Connection : Airport [$myvar1 : $myvar2]” echo “IP Address : $myen1” else echo “Connection : No Network” echo “IP Address : No Network” fi
fi
echo “Router : $router”
if [ “$router = “$dns ]
then echo “DNS Servers: No DNS Detected”
else dns=‘system_profiler SPNetworkDataType | grep -e “Server Addresses: “ | awk ‘{print $3, $4}’‘ echo “DNS Servers: $dns”
fi
echo “External : $ext1”
echo “ISP : $isp1”
================================================================
The above script detects:
1. Connection Type – Ethernet/Airport/Both (If Airport is active it detects the network name and its channel no.)
2. Local IP address of either or both the connection types
3. IP address of the router
4. DNS servers – if configured
5. External IP address
6. Name of the ISP – Tested to be working for two major broadband providers available locally

I would really like to know your views about the script.

Sorry for the long post, i am really excited using the Geektool and have been trying to optimize this code using different method to generate the results.

Thanks

Reply
The content of this field is kept private and will not be shown publicly.
2 + 10 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.