hi,
i have a script on my linux box that i have written
to run it you basically type ethinfo eth0
and it returns basic information about the adapters configuration ( ip, subnet, and adapter type ie ethernet or local )
this script is for the benifit of my boss who can't seem to get to grips with ifconfigs out put
how would i go about getting my script to check if the interface exists first then printing its output? ( code below)
thanks
antken
here is the script:
Code:
#!/bin/sh
e_ip=`/sbin/ifconfig $1 | grep inet | cut -f 2 -d : | cut -d ' ' -f 1`
e_snet=`/sbin/ifconfig $1 | grep Mas | cut -d : -f 4`
e_typ=`/sbin/ifconfig $1 | grep encap | cut -f 2 -d : | cut -d ' ' -f 1`
echo
echo IP Configuration for interface $1 is:
echo
echo This interface is: $e_typ
echo IP address: $e_ip
echo Subnet: $e_snet
echo
exit 0