×
Back to Geneos FAQ
How to set up a command to run a bash script with variables
When defining the user command, you need to call shell with the -c option and in parenthesis declare the variable name definition followed by a space in the argument to pass to the shell script.
Note
The arguments in the parenthesis need to use the concatenate setting to combine them into a single string to pass tobin/sh -c.
The following is an example script that will echo hello followed by the $(varname) variable value to standard out.
[mmuniz@myserver tmp]$ cat /tmp/hello_variable.sh#!/bin/bashecho helloecho ${varname}
The following user command passes the $(varname) variable definition to the /tmp/hello\_variable.sh script
Command XML:
<command name="Echo hello variable command"><targets><target>/geneos/gateway/directory/probe/managedEntity</target></targets><userCommand><type>script</type><runLocation>netprobe</runLocation><args><arg><static>/bin/sh</static></arg><arg><concatenate>false</concatenate><static>-c</static></arg><arg><concatenate>false</concatenate><static>(varname</static></arg><arg><concatenate>true</concatenate><static>=</static></arg><arg><concatenate>true</concatenate><static>value</static></arg><arg><concatenate>true</concatenate><static> </static></arg><arg><concatenate>true</concatenate><static>/tmp/hello_variable.sh)</static></arg></args><enablePassword>true</enablePassword></userCommand></command>
["Geneos"]
["Geneos > Gateway"]
["FAQ"]