<h1>Running shell commands to fetch results<aclass="headerlink"href="#running-shell-commands-to-fetch-results"title="Permalink to this headline">¶</a></h1>
<p>Previously, with searx you could search over the Internet on other people’s
computers. Now it is possible to fetch results from your local machine without
connecting to any networks from the same graphical user interface.</p>
<h2>Command line engines<aclass="headerlink"href="#command-line-engines"title="Permalink to this headline">¶</a></h2>
<p>In <aclass="reference external"href="https://github.com/searx/searx/pull/2128">PR 2128</a> a new type of engine has been introduced called <codeclass="docutils literal notranslate"><spanclass="pre">command</span></code>.
This engine lets administrators add engines which run arbitrary shell commands
and show its output on the web UI of searx.</p>
<p>When creating and enabling a <codeclass="docutils literal notranslate"><spanclass="pre">command</span></code> engine on a public searx instance,
you must be careful to avoid leaking private data. The easiest solution
is to add tokens to the engine. Thus, only those who have the appropriate token
can retrieve results from the it.</p>
<p>The engine base is flexible. Only your imagination can limit the power of this engine. (And
maybe security concerns.) The following options are available:</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">command</span></code>: A comma separated list of the elements of the command. A special token {{QUERY}} tells searx where to put the search terms of the user. Example: <codeclass="docutils literal notranslate"><spanclass="pre">['ls',</span><spanclass="pre">'-l',</span><spanclass="pre">'-h',</span><spanclass="pre">'{{QUERY}}']</span></code></p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">delimiter</span></code>: A dict containing a delimiter char and the “titles” of each element in keys.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">parse_regex</span></code>: A dict containing the regular expressions for each result key.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">query_type</span></code>: The expected type of user search terms. Possible values: <codeclass="docutils literal notranslate"><spanclass="pre">path</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">enum</span></code>. <codeclass="docutils literal notranslate"><spanclass="pre">path</span></code> checks if the uesr provided path is inside the working directory. If not the query is not executed. <codeclass="docutils literal notranslate"><spanclass="pre">enum</span></code> is a list of allowed search terms. If the user submits something which is not included in the list, the query returns an error.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">query_enum</span></code>: A list containing allowed search terms if <codeclass="docutils literal notranslate"><spanclass="pre">query_type</span></code> is set to <codeclass="docutils literal notranslate"><spanclass="pre">enum</span></code>.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">working_dir</span></code>: The directory where the command has to be executed. Default: <codeclass="docutils literal notranslate"><spanclass="pre">.</span></code></p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">result_separator</span></code>: The character that separates results. Default: <codeclass="docutils literal notranslate"><spanclass="pre">\n</span></code></p></li>
</ul>
<p>The example engine below can be used to find files with a specific name in the configured
<h2>Acknowledgement<aclass="headerlink"href="#acknowledgement"title="Permalink to this headline">¶</a></h2>
<p>This development was sponsored by <aclass="reference external"href="https://nlnet.nl/discovery">Search and Discovery Fund</a> of <aclass="reference external"href="https://nlnet.nl/">NLnet Foundation</a> .</p>