I'm working on cleaning up our licensing for Parallels as we have a few different license keys that have been used over the years.
I'm trying to build an Extension Attribute that either provides me the key or tell me it's "wrong". If the license key is the correct one it will have a line "key_number=" and the key will begin with "PDEI". If it doesn't have the correct key, this line either won't exist or the key will be something other than "PDEI".
I'm a total rookie at scripting so what I've put together is purely by piecing together other scripts with a whole lot of trial and error. Here is what I've come up with so far.
PDKey=$(prlsrvctl info --license | grep 'key_number' | awk '{print $1}')
if [ $PDKey -eq 0 ];
then
echo "<result>Wrong</result>"
else
echo "<result>$PDKey</result>"
fi
This is the error I get on a machine with the correct key:
-bash: [: key_number="PDEI.xxxxxxxx.xxxxx": integer expression expected
<result>key_number="PDEI.xxxxxxxx.xxxxx"</result>
This is the error I get on a machine with an incorrect key:
-bash: [ -eq: unary operation expected
<result></result>
I would be truly greatfull if anyone is able to help me clean this up or has an easier way to do this.
Thanks!
Kenny
