×
Back to Geneos FAQ
How can I capture username in a command?
In your command you will have to add an argument xpath: /geneos/client/runtimeParameters/@Username. This will get the username and you may pass this as a parameter.
There are a few XPaths available to capture info of the Active Console, they are:
- /geneos/client/parameters/@HostName - /geneos/client/runtimeParameters/@Username (Username only without domain name) - /geneos/client/runtimeParameters/@Domain (Domain name)
As an example, below is a Putty command using the username to connect to a Unix server:
<command name="GW2_Putty_with_username"> <targets> <target>/geneos/gateway/directory/probe[wild(rparam("OS"),"Linux*")]/managedEntity[wild(@name,"nysupsvr*")]</target> <target>/geneos/gateway/directory/probe[wild(rparam("OS"),"S*")]/managedEntity</target> </targets> <userCommand> <type>script</type> <runLocation>client</runLocation> <args> <arg> <static>"C:\Program Files\PuTTY\putty.exe"</static> </arg> <arg> <xpath>ancestor::probe/parameters/@HostName</xpath> </arg> <arg> <static>-l</static> </arg> <arg> <xpath>/geneos/client/runtimeParameters/@Username</xpath> </arg> </args> </userCommand> </command>
["Geneos"]
["Geneos > Gateway"]
["FAQ"]