Sorry to hijack an old thread. But we're trying to pull the installed Parallels Desktop.app serial number.
How do we take this:
$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }'
serial="XXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
And trim the output, so we can have an EA that shows just the serial number:
$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }' | <insert-missing-logic>
XXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
Try this one:
$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }' | cut -f2 -d'='
This tells cut to use '=' as a delimiter. Everything before '=' is field 1 (serial), everything after is field 2 (desired output). Specifying -f2 tells cut we just want field 2.
I don't have Parallels to test, but this may also work:
prlsrvctl info --license | awk -F'"' '/serial/{print $2}'
Explanation:
Pull the data from prlsrvctl info
passing to | awk
, set up awk's field separator -F
to be a quote mark '"'
, use awk's regex matching to only look at lines including "serial" in them '/serial/
and print field 2 {print $2}'
(which happens to be the string between the quote marks)
Wow you guys rock, I'll get this into an EA and will punt this over to the EA here on JAMF Nation section with full credit to you guys.
#!/bin/sh
if [ -f "/usr/local/bin/prlsrvctl" ]; then
echo "<result>`/usr/local/bin/prlsrvctl info --license | awk -F '"' '/serial/{print $2}'`</result>"
else
echo "<result>"NotInstalled"</result>"
fi
Craig Peterson (Parallels) gave us a couple more tips, will send them in for EA approval:
is_volume= returns yes for PDB or no for consumer (requires 10.1.2 or later for this to work):
prlsrvctl info --license | awk -F'"' '/is_volume/{print $2}'
One other tip from Craig (Parallels)...
Parallels Desktop older than 10.1.1 or older will show key_number which would follow a PDEI.xxxxxxxx.00xx format.
Parallels Desktop 10.1.2 or later won't include a key_number value.
Is there a way to do the if statement in a way that if key_number returns no value, echo NoValue. If key_value returns a value, echo that value?
Here is the command:
/usr/local/bin/prlsrvctl info --license | awk -F '"' '/key_value/{print $2}'
@donmontalvo There are probably a few different ways you can approach this. The simplest way might be to check for a null value being returned by the command and then echoing back the appropriate string in the if/then section. For example:
#!/bin/sh
keyvalue=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/key_value/{print $2}')
if [ -z "$keyvalue" ]; then
echo "<result>No Value</result>"
else
echo "<result>$keyvalue</result>"
fi
In the first command I'm piping errors to /dev/null 2>/dev/null
I'm not certain if that's necessary since I don't have the /usr/local/bin/prlsrvctl
binary on my Mac to check that with, but its a good idea in case you would normally get an error back or some string like "No value" etc. Since the if/then statement checks for a null value, we want to be sure nothing gets returned other than a valid key_value string.
Try that and see how it works. You'll need to test it on both 10.1.1 or older and 10.1.2 or newer versions to be sure.
@mm2270 nice, how does this look for returning $key_value if an old version (pre-10.1.2) is installed, or $serial if a new version (10.1.2 or later) is installed?
FYI, Only Parallels 10.1.2 or later is supported by their License Portal.
Mucho danke!
Don
#!/bin/sh
key_value=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/key_value/{print $2}')
serial=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/serial/{print $2}')
if [ -f "/usr/local/bin/prlsrvctl" ]; then
if [ -z "$key_value" ]; then
echo "<result>$serial</result>"
else
echo "<result>$key_value</result>"
fi
else
echo "<result>"NotInstalled"</result>"
fi
@Josh.Smith thanks for the command, we tested and found it included the quotes, so we went with the other. Both work though. Going to JNUC2015?
Hi Don,
Looks OK from here, but again, I don't have the product here to test with. If it returns what you're after, then I'd say go for it.
This is great!!
I am adding it to our EA list is there a way of extracting the Version that is installed?