I'm writing a bash script for inventory information, and i'm attempting to collect data on two seperate version of Red Hat. They have two different types of output for the ifconfig, so i'm simply trying to add an 'if' statement to the already working function. I keep getting an error that says syntax error: unexpected end of file
. I assume i'm not closing something somewhere, but I can't seem to see it, though i've probably been looking at it too long. any assistance would be great.
Here is the script
#!/bin/sh
OS_VERSION=`cat /etc/redhat-release |awk '{print $0}'`
pat=".*Santiago.*"
num=1
if [[ "$OS_VERSION" =~ $pat ]]; then
for i in `/sbin/ifconfig -a |grep -i -B 3 "UP" |grep -i "HWaddr"|awk '{print $1}'`
do
{
MacAddress=`/sbin/ifconfig $i |grep -i -B 3 "UP" |grep -i "HWaddr"| awk '{print $NF}'`
Ip_Address=`/sbin/ifconfig $i|grep -i "inet addr"|awk '{print $2}'|awk -F: '{print $2}'`
echo -n "ethName$num=$i | ethMac$num=\"$MacAddress\" | ethIp$num=\"$Ip_Address\" | "
num=$(expr $num+1|bc)
}
else
echo "Not Santiago, use other script"
done;
echo "";
exit
Aucun commentaire:
Enregistrer un commentaire