I'm working on a bash script and ran into an issue. I'm pushing what I know from using normal if/fi statements and trying to use them to set variables related to picking up the OS version, such as RH 7, Debian 7, Ubuntu, etc. The problem I'm having is that it's just not working like I thought it would. I run each part by hand and it works just fine, but when I put everything in a script, nothing.
Is there a better way to do this? Thank you in advance
value1=$(cat /etc/redhat-release | awk '{ print $4 }' | cut -c 1) value2=$(cat /etc/redhat-release | awk '{ print $3 }' | cut -c 1) value3=$(lsb_release -sr) value4=$(cat /etc/debian_version) if [[ $value1 -eq 7 ]] && [[ -e /etc/redhat-release ]]; then OS=RedHat VER=RH7 elif [[ $value2 -eq 6 ]] && [[ -e /etc/redhat-release ]]; then OS=RedHat VER=RH6 elif [[ $value3 = 14.04 ]]; then OS=Ubuntu VER=UB1404 elif [[ -e /etc/debian_version ]] && [[ $value4 -eq 7 ]]; then OS=Debian VER=DEB7 fi
facter. Why are you trying to do this?python -m platformwill provide output:Linux-3.2.0-4-amd64-x86_64-with-debian-7.3