Posted on 07-26-2022 01:27 PM
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.
Solved! Go to Solution.
Posted on 07-26-2022 01:45 PM
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.
Posted on 07-26-2022 01:45 PM
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.
Posted on 07-26-2022 01:50 PM
Not a typo but a brain fart. Thank @mm2270