Skip to main content
Solved

Extract Version from Tool not listed as .APP

  • July 26, 2022
  • 2 replies
  • 8 views

Forum|alt.badge.img+10

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.

Best answer by mm2270

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.

2 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • Answer
  • July 26, 2022

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.


Forum|alt.badge.img+10
  • Author
  • Valued Contributor
  • 134 replies
  • July 26, 2022

Not a typo but a brain fart.  Thank @mm2270