The Rock
asked on
script output not proper as expected
Hi Experts,
I want to create a script for 2 hardwares dell and HP ..so if the dell hardware then nic will be em1 etc then it greps em1 IP and if HP then grep eth0 etc..and display eth0 ip.
please help
/sbin/ifconfig > /tmp/testnic
grep -q "em1" /tmp/testnic
# if not then create it
if [ $? -ne 0 ]; then
echo -e "
Address = `/sbin/ifconfig em1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
"
else
echo -e "
Address = `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
"
fi
rm -rf /tmp/testnic
I want to create a script for 2 hardwares dell and HP ..so if the dell hardware then nic will be em1 etc then it greps em1 IP and if HP then grep eth0 etc..and display eth0 ip.
please help
/sbin/ifconfig > /tmp/testnic
grep -q "em1" /tmp/testnic
# if not then create it
if [ $? -ne 0 ]; then
echo -e "
Address = `/sbin/ifconfig em1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
"
else
echo -e "
Address = `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
"
fi
rm -rf /tmp/testnic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER