search cancel

How to create a custom OneClick menu item that can prompt the user for input


Article ID: 15482


Updated On:


CA Spectrum


Spectrum OneClick can be extensively customised to suit user needs. This includes adding menus to the client that can provide functionality beyond the factory settings. Further scripting can add user input to this customisation as this KD will show.

How can you customise the OneClick menu so that it has an item that first prompts the user to input a value (either string or numeric) and then passes it as an argument ({0}) to a script which is run on the OneClick web server? 




To prompt the user for input which can then be used by the script, you would need to customise the script itself to prompt for the value.
So, as an example, the following is a script called on a OneClick server running on Linux:



echo "Enter word:"

read DATA

echo "You entered the word $DATA"

echo "Press the <Enter> key to continue:"

read DUMMY


When run, it prompts the user to enter a word. The user enters a word and presses enter. It returns the word entered by the user and then waits for the user to press the Enter key to continue.

To use this, you would then create a custom menu item under the Tools menu. For example;


  <menu name="">

    <item name="Test Script">









            <command>/usr/bin/xterm -e /home/myuser/</command>







The example above requires that the user have xterm software running on their OneClick client system (i.e their PC). However, this can be changed to reflect whatever terminal software you use that has similar capability.

When run, you would see xterm appear as per the attached screenshots. 

<Please see attached file for image>


Enter a word and press enter, it will output that word. Then press Enter again and the xterm disappears.

<Please see attached file for image>


This assumes the Linux DISPLAY environment variable is set to the users client machine (for example; export DISPLAY=localhost:0.0. You would need to set this in the .bashrc / .bash_profile or other environment settings file for whichever particular shell is being used on the Linux based OneClick server).

Another option is to write the script according to the OS and install the script on the client machine and use the <launch-application> tag. If the client OS is Windows, something similar to the following example could be used where <SCRIPT> would be the name of the script to run:


<command>cmd.exe /c start "My Script" cmd /c "<SCRIPT> &amp;&amp; pause"</command>


Additional Information

Please reference the "Customizing the OneClick Console Menu" section of the documentation for more information.


1558688406176000015482_sktwi1f5rjvs16flz.png get_app
1558688403321000015482_sktwi1f5rjvs16fly.png get_app