Here is command line that check current version of Mac OSX Sever: 

Full:     sw_vers

Only product version:   sw_vers | grep ‘ProductVersion:’ 

Just version number:   sw_vers | grep ‘ProductVersion:’ | grep -o ‘[0-9]*.[0-9]*.[0-9]*’