#!/bin/ksh
# script to get interface names
# numbering starts with 1

if [ $# = 1 ]; then
	if [ $1 -le 0 ]; then
		echo 'start counting at 1!'
		exit 2 
	fi
	interfaceCount=`ifconfig | grep ^[a-z] | grep -c -v -E 'pf|enc|lo'`
	if [ $1 -gt $interfaceCount ]; then
		echo 'Interface could not be found. Please specify an integer number'	
	echo 'There are only ' $interfaceCount ' interfaces available.' 
		exit 3 
	fi
	ifconfig | grep ^[a-z] | awk '{print $1 }' | sed 's/://' | grep -v -E 'pf|enc|lo' | head -$1 | tail -1
	exit 0
else
	echo 'Wrong arguments'
	echo 'usage: ' $0' <InterfaceNumber>'
	exit 1
fi


