Extract Version from Tool not listed as .APP

sgiesbrecht
Contributor III

Trying to export the version of an install (security) application that does not use the standard .App format.

When I run the command /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' in Terminal, it outputs the correct information.


When I try to use it in a variable AgentVer=( /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' ) (for EA) I get error "-sh: syntax error near unexpected token `2'" so I know it has to do with the special characters but don't know how to allow them.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

I'm not sure if what you posted was a typo or not, but this

AgentVer=( /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' )

is not a variable. You have to have the $ character before the open paren mark, so this instead

AgentVer=$( /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' )

So try that and see if it works for you.

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

I'm not sure if what you posted was a typo or not, but this

AgentVer=( /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' )

is not a variable. You have to have the $ character before the open paren mark, so this instead

AgentVer=$( /usr/local/agent/agent --version 2>&1  | awk '/Agent/ {print $NF}' )

So try that and see if it works for you.

sgiesbrecht
Contributor III

Not a typo but a brain fart.  Thank @mm2270