Custom Commands

The Custom Commands module provides a simple interface to every single command on your server at the press of a button. It sounds pretty impressive. Unfortunately, you actually have to create those command buttons before you can use them. The simplest way to document it is to create an example custom command and demonstrate how it works (Figure 15-2).

click to expand
Figure 15-2: Create a new custom command

As you can see in the preceding figure, there is a command called pinger, which runs ping three times in succession for each of three computers on my network. The -c 5 sets ping to try to ping the host five times and then exit. The output of this command looks similar to Figure 15-3.

click to expand
Figure 15-3: Output from pinger custom command

It is also possible to accept options for your commands by choosing a type of input and naming it in the Command Parameters section of the Create Command page (Figure 15-4). To make the above example more flexible, you can change it so that any host may be pinged by the user of the command.

click to expand
Figure 15-4: Ping Host custom command

In the preceding figure, you'll see that a variable named $host has been added to the command. I've still chosen to force -c 5 to be included in the command, although it could also be made into a variable option. Now, the user can choose to enter any host name they wish to ping in the text entry field provided.

The way this feature works is that a variable name is assigned to each entry field you create in the Command Parameters section. You can then insert those variables contents into the command that is executed.

Note 

Beware that there have been security issues with allowing user-entered data on custom commands in the past. All known exploits have been fixed, but it is still probably a wise idea to carefully consider security implications before giving a normally untrusted user access to commands that allow arbitrary text entry.



The Book of Webmin... or How I Learned to Stop Worrying and Love UNIX
The Book of Webmin: Or How I Learned to Stop Worrying and Love UNIX
ISBN: 1886411921
EAN: 2147483647
Year: 2006
Pages: 142
Authors: Joe Cooper

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net