Before actual question few words about what I'm doing to grasp the idea.
I would want to add another cool feature to my Authentic Theme for Webmin.
I have made Command Shell module look/feel just if it was ordinary shell. However, as it's only a port, it has few limitations. One of them is missing shell autocomplete, when you hit Tab
key (or other based on the system: Esc+Esc
and/or Ctrl+I
).
My point is to make it work natively. I'm going to use an
XMLHttpRequest
call to the server and pass the part of entered command to the actual shell. The call will be triggered on the event of the Tab
key.
For example, when you're in Authentic Theme dropdown shell (you could see it on the video screencast above), and when you type, let's say, xa
and hit Tab
, the event will be triggered and make a request. Then the server receives a string xa
and we're ready to begin.
My questions are is:
1. What is the best way to execute such command in Perl?
2. How to properly escape such command to make sure that it won't be exploitable;
3. How to trigger programmatically Tab
key (to run autocomplete) in the system()
call;
4. How to grep output.
On the respond, using xa
as an example, I expect to get xargs
on the results.
I'm aware about possibly of ambiguity of the passed command, for example, when using sys
, and when autocomplete wouldn't work on the single Tab
key. I think it's better to exclude this from the scope of current question.