i have a test for a device where i am using: "if-config lan1 up" and right after check if it was able to connect(succeed with if-config up) with "ethtool lan1".
but before it can get up it already check if LAN 1 is connected, so it telling me its not connected, even so after some second it succeed to connect. can i make ethtool wait for "if-config up" to finish or fail before it check the connection? can i do it with no sleep command???? i tried wait but it didn't work
code below:
function ethernet_up_and_test(){
ifconfig $1 up
interface=$1
expected_link_speed=$2
interfaceName=$3
ethtool_response=`ethtool ${interface}`
link_detected=`echo -e "${ethtool_response}" | grep "Link detected:" | cut -d" " -f3`
if [ "x${link_detected}" != "xyes" ]; then
echo -e "*** ${interfaceName} - no link detected ***"
return -1
fi
actual_link_speed=`echo -e "${ethtool_response}" | grep "Speed:" | cut -d" " -f2`
if [ "x${actual_link_speed}" != "x${expected_link_speed}" ]; then
echo -e "link speed is: ${actual_link_speed}"
return -1
fi
echo -e "PASSED"
return 0
}
for example it get ethernet_up_and_test lan1 1000Mb/s LAN1