New here? Register and read our Community Rules. Accounts are approved by hand.

Scripts Detect Network Interface Centos

Hi,

This is my scripts detect network interface in centos (eth vs venet).

#!/bin/sh
RED='\033[01;31m'
GREEN='\033[01;32m'
RESET='\033[0m'
clear

if [ "/sbin/ifconfig | grep venet" ];then
        echo -e "[ $GREEN venet $RESET ]"
else
        echo -e "[ $RED eth0 $RESET ]"
fi

when i test script it have error

: command not foundne 5: clear
: command not foundne 6:
testifconfig.sh: line 12: syntax error: unexpected end of file

Someone can fix it for me?

Regards,

Comments

  • 
    #!/bin/sh
    RED='\033[01;31m'
    GREEN='\033[01;32m'
    RESET='\033[0m'
    clear
    
    /sbin/ifconfig | grep venet >/dev/null 2>&1
    RET=$?
    if [ $RET -eq 0 ]; then
      echo -e "[ $GREEN venet $RESET ]"
    else
      echo -e "[ $RED eth0 $RESET ]"
    fi
    
    
  • : command not foundne 5: clear
    : command not foundne 6:
    : ambiguous redirecte 7: 1
    testifconfig.sh: line 14: syntax error: unexpected end of file
    
  • imchandaveimchandave Member
    edited September 2014

    Are you creating testifconfig.sh on a Windows machine and then uploading it to your CentOS machine?

    If that's the case the problem might be end-of-line markers. Use dos2unix to convert the '\r\n's time '\n's.

    For the "clear" problem, make sure you have the program in your path.

    See ya...

    d.c.

  • It working now. Thank you. Mod can closed topic.

Sign In or Register to comment.