View Single Post
  #4   (View Single Post)  
Old 2nd February 2011
isthistheend isthistheend is offline
New User
 
Join Date: Feb 2011
Posts: 4
Lightbulb

Thank you ocicat and J65nko..
i was thinking about using "for" but i wasnt sure how to use it. I get all of code now. i add the code
Code:
#!/bin/sh

name=$(ifconfig |grep -E 'flags' |grep -v lo |grep -v enc |awk -F":" '{print $1}')
ip=$(ifconfig |grep -E 'inet' |grep -v inet6 | grep -v 127.0.0.1 |awk '{print $2}')
status=$(ifconfig | grep status | awk '{print $2}')

for X in $name ; do
    ip=$(ifconfig $X  | grep 'inet ' | awk '{print $2}')
    status=$(ifconfig $X | grep status | awk -F ":" '{print $2}')
cat <<END
Interface name: $X  IP address: $ip Status: $status
END
done
my output:
Code:
Interface name: bge0  IP address: 10.10.35.12 Status: active
Interface name: bge1  IP address:  Status: no carrier
Now i'm looking for adding "No IP" or something like that when interface have no ip or carrier, like:
Interface name: bge1 IP address:"No Ip Address" Status: no carrier

i think "if" will solve the stuation (:
Thank you both again..
Reply With Quote