---
title: "How to extract a Managed Entity's attribute and use it in a command argument"
description: "Extracting a Managed Entity's attribute involves using XPath to retrieve specific attribute values. The extracted attribute value can then be used as an argument in a command within Geneos."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004021785-geneos-how-to-extract-a-managed-entity-s-attribute-and-use-it-in-a-command-argument/index.html"
---
## Solution

Use the following XPath:

```
ancestor::managedEntity/attributes/attribute[@name="<attribute name>"]/@value
```

e.g.

```
ancestor::managedEntity/attributes/attribute[@name="OS"]/@value
```

## Sample XML

The sample command extracts the value of an attribute named "OS" from a headline cell.

```
<command name="Get ME Attribute Netprobe">
<targets>
<target>/geneos/gateway[(@name=&quot;MNL_MAYA_GATEWAY_9370&quot;)]/directory/probe/managedEntity/sampler/dataview/headlines/cell</target>
</targets>
<userCommand>
<type>script</type>
<runLocation>netprobe</runLocation>
<args>
<arg>
<static>/home/MNL/rgonzales/scripts/scripts/print_args.bash</static>
</arg>
<arg>
<userInput>
<description>ME Attribute</description>
<xpathOptions>
<xpathOption>ancestor::managedEntity/attributes/attribute[@name=&quot;OS&quot;]/@value</xpathOption>
</xpathOptions>
</userInput>
</arg>
<arg>
<userInput>
<description>Headline Name</description>
<xpathOptions>
<xpathOption>ancestor::dataview/headlines/cell/@name</xpathOption>
</xpathOptions>
</userInput>
</arg>
<arg>
<xpath>@name</xpath>
</arg>
<arg>
<xpath>@value</xpath>
</arg>
</args>
<enablePassword>true</enablePassword>
</userCommand>
</command>
```


