command-line-engines.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../../../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <title>Command Line Engines &#8212; SearXNG Documentation (2025.5.1+1a1628149)</title>
  8. <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=6625fa76" />
  9. <link rel="stylesheet" type="text/css" href="../../../_static/searxng.css?v=52e4ff28" />
  10. <script src="../../../_static/documentation_options.js?v=cc9fc81d"></script>
  11. <script src="../../../_static/doctools.js?v=9a2dae69"></script>
  12. <script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
  13. <script data-project="searxng" data-version="2025.5.1+1a1628149" src="../../../_static/describe_version.js?v=fa7f30d0"></script>
  14. <link rel="index" title="Index" href="../../../genindex.html" />
  15. <link rel="search" title="Search" href="../../../search.html" />
  16. <link rel="next" title="NoSQL databases" href="nosql-engines.html" />
  17. <link rel="prev" title="Demo Offline Engine" href="../demo/demo_offline.html" />
  18. </head><body>
  19. <div class="related" role="navigation" aria-label="Related">
  20. <h3>Navigation</h3>
  21. <ul>
  22. <li class="right" style="margin-right: 10px">
  23. <a href="../../../genindex.html" title="General Index"
  24. accesskey="I">index</a></li>
  25. <li class="right" >
  26. <a href="../../../py-modindex.html" title="Python Module Index"
  27. >modules</a> |</li>
  28. <li class="right" >
  29. <a href="nosql-engines.html" title="NoSQL databases"
  30. accesskey="N">next</a> |</li>
  31. <li class="right" >
  32. <a href="../demo/demo_offline.html" title="Demo Offline Engine"
  33. accesskey="P">previous</a> |</li>
  34. <li class="nav-item nav-item-0"><a href="../../../index.html">SearXNG Documentation (2025.5.1+1a1628149)</a> &#187;</li>
  35. <li class="nav-item nav-item-1"><a href="../../index.html" >Developer documentation</a> &#187;</li>
  36. <li class="nav-item nav-item-2"><a href="../index.html" accesskey="U">Engine Implementations</a> &#187;</li>
  37. <li class="nav-item nav-item-this"><a href="">Command Line Engines</a></li>
  38. </ul>
  39. </div>
  40. <div class="document">
  41. <div class="documentwrapper">
  42. <div class="bodywrapper">
  43. <div class="body" role="main">
  44. <section id="command-line-engines">
  45. <span id="engine-command"></span><h1>Command Line Engines<a class="headerlink" href="#command-line-engines" title="Link to this heading">¶</a></h1>
  46. <aside class="sidebar">
  47. <p class="sidebar-title">info</p>
  48. <ul class="simple">
  49. <li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/command.py">command.py</a></p></li>
  50. <li><p><a class="reference internal" href="../index.html#offline-engines"><span class="std std-ref">Offline Engines</span></a></p></li>
  51. </ul>
  52. </aside>
  53. <nav class="contents local" id="contents">
  54. <ul class="simple">
  55. <li><p><a class="reference internal" href="#configuration" id="id1">Configuration</a></p></li>
  56. <li><p><a class="reference internal" href="#example" id="id2">Example</a></p></li>
  57. <li><p><a class="reference internal" href="#implementations" id="id3">Implementations</a></p></li>
  58. </ul>
  59. </nav>
  60. <aside class="sidebar">
  61. <p class="sidebar-title">info</p>
  62. <p>Initial sponsored by <a class="reference external" href="https://nlnet.nl/discovery">Search and Discovery Fund</a> of <a class="reference external" href="https://nlnet.nl/">NLnet Foundation</a>.</p>
  63. </aside>
  64. <p id="module-searx.engines.command">With <em>command engines</em> administrators can run engines to integrate arbitrary
  65. shell commands.</p>
  66. <div class="admonition attention">
  67. <p class="admonition-title">Attention</p>
  68. <p>When creating and enabling a <code class="docutils literal notranslate"><span class="pre">command</span></code> engine on a public instance, you
  69. must be careful to avoid leaking private data.</p>
  70. </div>
  71. <p>The easiest solution is to limit the access by setting <code class="docutils literal notranslate"><span class="pre">tokens</span></code> as described
  72. in section <a class="reference internal" href="../../../admin/settings/settings_engines.html#private-engines"><span class="std std-ref">Private Engines (tokens)</span></a>. The engine base is flexible. Only your
  73. imagination can limit the power of this engine (and maybe security concerns).</p>
  74. <section id="configuration">
  75. <h2><a class="toc-backref" href="#id1" role="doc-backlink">Configuration</a><a class="headerlink" href="#configuration" title="Link to this heading">¶</a></h2>
  76. <p>The following options are available:</p>
  77. <dl>
  78. <dt><code class="docutils literal notranslate"><span class="pre">command</span></code>:</dt><dd><p>A comma separated list of the elements of the command. A special token
  79. <code class="docutils literal notranslate"><span class="pre">{{QUERY}}</span></code> tells where to put the search terms of the user. Example:</p>
  80. <div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">[</span><span class="s">&#39;ls&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;-l&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;-h&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;{{QUERY}}&#39;</span><span class="p p-Indicator">]</span>
  81. </pre></div>
  82. </div>
  83. </dd>
  84. <dt><code class="docutils literal notranslate"><span class="pre">delimiter</span></code>:</dt><dd><p>A mapping containing a delimiter <code class="docutils literal notranslate"><span class="pre">char</span></code> and the <em>titles</em> of each element in
  85. <code class="docutils literal notranslate"><span class="pre">keys</span></code>.</p>
  86. </dd>
  87. <dt><code class="docutils literal notranslate"><span class="pre">parse_regex</span></code>:</dt><dd><p>A dict containing the regular expressions for each result key.</p>
  88. </dd>
  89. </dl>
  90. <p><code class="docutils literal notranslate"><span class="pre">query_type</span></code>:</p>
  91. <blockquote>
  92. <div><p>The expected type of user search terms. Possible values: <code class="docutils literal notranslate"><span class="pre">path</span></code> and
  93. <code class="docutils literal notranslate"><span class="pre">enum</span></code>.</p>
  94. <dl class="simple">
  95. <dt><code class="docutils literal notranslate"><span class="pre">path</span></code>:</dt><dd><p>Checks if the user provided path is inside the working directory. If not,
  96. the query is not executed.</p>
  97. </dd>
  98. <dt><code class="docutils literal notranslate"><span class="pre">enum</span></code>:</dt><dd><p>Is a list of allowed search terms. If the user submits something which is
  99. not included in the list, the query returns an error.</p>
  100. </dd>
  101. </dl>
  102. </div></blockquote>
  103. <dl class="simple">
  104. <dt><code class="docutils literal notranslate"><span class="pre">query_enum</span></code>:</dt><dd><p>A list containing allowed search terms if <code class="docutils literal notranslate"><span class="pre">query_type</span></code> is set to <code class="docutils literal notranslate"><span class="pre">enum</span></code>.</p>
  105. </dd>
  106. <dt><code class="docutils literal notranslate"><span class="pre">working_dir</span></code>:</dt><dd><p>The directory where the command has to be executed. Default: <code class="docutils literal notranslate"><span class="pre">./</span></code>.</p>
  107. </dd>
  108. <dt><code class="docutils literal notranslate"><span class="pre">result_separator</span></code>:</dt><dd><p>The character that separates results. Default: <code class="docutils literal notranslate"><span class="pre">\n</span></code>.</p>
  109. </dd>
  110. </dl>
  111. </section>
  112. <section id="example">
  113. <h2><a class="toc-backref" href="#id2" role="doc-backlink">Example</a><a class="headerlink" href="#example" title="Link to this heading">¶</a></h2>
  114. <p>The example engine below can be used to find files with a specific name in the
  115. configured working directory:</p>
  116. <div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">find</span>
  117. <span class="w"> </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">command</span>
  118. <span class="w"> </span><span class="nt">command</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="s">&#39;find&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;.&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;-name&#39;</span><span class="p p-Indicator">,</span><span class="w"> </span><span class="s">&#39;{{QUERY}}&#39;</span><span class="p p-Indicator">]</span>
  119. <span class="w"> </span><span class="nt">query_type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">path</span>
  120. <span class="w"> </span><span class="nt">shortcut</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">fnd</span>
  121. <span class="w"> </span><span class="nt">delimiter</span><span class="p">:</span>
  122. <span class="w"> </span><span class="nt">chars</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;</span><span class="nv"> </span><span class="s">&#39;</span>
  123. <span class="w"> </span><span class="nt">keys</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">[</span><span class="s">&#39;line&#39;</span><span class="p p-Indicator">]</span>
  124. </pre></div>
  125. </div>
  126. </section>
  127. <section id="implementations">
  128. <h2><a class="toc-backref" href="#id3" role="doc-backlink">Implementations</a><a class="headerlink" href="#implementations" title="Link to this heading">¶</a></h2>
  129. </section>
  130. <dl class="py function">
  131. <dt class="sig sig-object py" id="searx.engines.command.check_parsing_options">
  132. <span class="sig-prename descclassname"><span class="pre">searx.engines.command.</span></span><span class="sig-name descname"><span class="pre">check_parsing_options</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine_settings</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/searx/engines/command.html#check_parsing_options"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.engines.command.check_parsing_options" title="Link to this definition">¶</a></dt>
  133. <dd><p>Checks if delimiter based parsing or regex parsing is configured correctly</p>
  134. </dd></dl>
  135. </section>
  136. <div class="clearer"></div>
  137. </div>
  138. </div>
  139. </div>
  140. <span id="sidebar-top"></span>
  141. <div class="sphinxsidebar" role="navigation" aria-label="Main">
  142. <div class="sphinxsidebarwrapper">
  143. <p class="logo"><a href="../../../index.html">
  144. <img class="logo" src="../../../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
  145. </a></p>
  146. <h3><a href="../../../index.html">Table of Contents</a></h3>
  147. <ul class="current">
  148. <li class="toctree-l1"><a class="reference internal" href="../../../user/index.html">User information</a></li>
  149. <li class="toctree-l1"><a class="reference internal" href="../../../own-instance.html">Why use a private instance?</a></li>
  150. <li class="toctree-l1"><a class="reference internal" href="../../../admin/index.html">Administrator documentation</a></li>
  151. <li class="toctree-l1 current"><a class="reference internal" href="../../index.html">Developer documentation</a><ul class="current">
  152. <li class="toctree-l2"><a class="reference internal" href="../../quickstart.html">Development Quickstart</a></li>
  153. <li class="toctree-l2"><a class="reference internal" href="../../rtm_asdf.html">Runtime Management</a></li>
  154. <li class="toctree-l2"><a class="reference internal" href="../../contribution_guide.html">How to contribute</a></li>
  155. <li class="toctree-l2"><a class="reference internal" href="../../extended_types.html">Extended Types</a></li>
  156. <li class="toctree-l2 current"><a class="reference internal" href="../index.html">Engine Implementations</a><ul class="current">
  157. <li class="toctree-l3"><a class="reference internal" href="../enginelib.html">Engine Library</a></li>
  158. <li class="toctree-l3"><a class="reference internal" href="../engines.html">SearXNG’s engines loader</a></li>
  159. <li class="toctree-l3"><a class="reference internal" href="../engine_overview.html">Engine Overview</a></li>
  160. <li class="toctree-l3"><a class="reference internal" href="../index.html#resultlist-and-engines">ResultList and engines</a></li>
  161. <li class="toctree-l3 current"><a class="reference internal" href="../index.html#engine-types">Engine Types</a><ul class="current">
  162. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-engines">Online Engines</a></li>
  163. <li class="toctree-l4 current"><a class="reference internal" href="../index.html#offline-engines">Offline Engines</a><ul class="current">
  164. <li class="toctree-l5"><a class="reference internal" href="../offline_concept.html">Offline Concept</a></li>
  165. <li class="toctree-l5"><a class="reference internal" href="../demo/demo_offline.html">Demo Offline Engine</a></li>
  166. <li class="toctree-l5 current"><a class="current reference internal" href="#">Command Line Engines</a></li>
  167. <li class="toctree-l5"><a class="reference internal" href="nosql-engines.html">NoSQL databases</a></li>
  168. <li class="toctree-l5"><a class="reference internal" href="search-indexer-engines.html">Local Search APIs</a></li>
  169. <li class="toctree-l5"><a class="reference internal" href="sql-engines.html">SQL Engines</a></li>
  170. </ul>
  171. </li>
  172. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-url-search">Online URL Search</a></li>
  173. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-currency">Online Currency</a></li>
  174. <li class="toctree-l4"><a class="reference internal" href="../index.html#online-dictionary">Online Dictionary</a></li>
  175. </ul>
  176. </li>
  177. </ul>
  178. </li>
  179. <li class="toctree-l2"><a class="reference internal" href="../../result_types/index.html">Result Types</a></li>
  180. <li class="toctree-l2"><a class="reference internal" href="../../templates.html">Simple Theme Templates</a></li>
  181. <li class="toctree-l2"><a class="reference internal" href="../../search_api.html">Search API</a></li>
  182. <li class="toctree-l2"><a class="reference internal" href="../../plugins/index.html">Plugins</a></li>
  183. <li class="toctree-l2"><a class="reference internal" href="../../answerers/index.html">Answerers</a></li>
  184. <li class="toctree-l2"><a class="reference internal" href="../../translation.html">Translation</a></li>
  185. <li class="toctree-l2"><a class="reference internal" href="../../lxcdev.html">Developing in Linux Containers</a></li>
  186. <li class="toctree-l2"><a class="reference internal" href="../../makefile.html">Makefile &amp; <code class="docutils literal notranslate"><span class="pre">./manage</span></code></a></li>
  187. <li class="toctree-l2"><a class="reference internal" href="../../reST.html">reST primer</a></li>
  188. <li class="toctree-l2"><a class="reference internal" href="../../searxng_extra/index.html">Tooling box <code class="docutils literal notranslate"><span class="pre">searxng_extra</span></code></a></li>
  189. </ul>
  190. </li>
  191. <li class="toctree-l1"><a class="reference internal" href="../../../utils/index.html">DevOps tooling box</a></li>
  192. <li class="toctree-l1"><a class="reference internal" href="../../../src/index.html">Source-Code</a></li>
  193. </ul>
  194. <h3>Project Links</h3>
  195. <ul>
  196. <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  197. <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  198. <li><a href="https://searx.space">Public instances</a>
  199. <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  200. </ul><h3>Navigation</h3>
  201. <ul>
  202. <li><a href="../../../index.html">Overview</a>
  203. <ul>
  204. <li><a href="../../index.html">Developer documentation</a>
  205. <ul>
  206. <li><a href="../index.html">Engine Implementations</a>
  207. <ul>
  208. <li>Previous: <a href="../demo/demo_offline.html" title="previous chapter">Demo Offline Engine</a>
  209. <li>Next: <a href="nosql-engines.html" title="next chapter">NoSQL databases</a></ul>
  210. </li></ul>
  211. </li>
  212. </ul>
  213. </li>
  214. </ul>
  215. <search id="searchbox" style="display: none" role="search">
  216. <h3 id="searchlabel">Quick search</h3>
  217. <div class="searchformwrapper">
  218. <form class="search" action="../../../search.html" method="get">
  219. <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
  220. <input type="submit" value="Go" />
  221. </form>
  222. </div>
  223. </search>
  224. <script>document.getElementById('searchbox').style.display = "block"</script>
  225. <div role="note" aria-label="source link">
  226. <h3>This Page</h3>
  227. <ul class="this-page-menu">
  228. <li><a href="../../../_sources/dev/engines/offline/command-line-engines.rst.txt"
  229. rel="nofollow">Show Source</a></li>
  230. </ul>
  231. </div>
  232. </div>
  233. </div>
  234. <div class="clearer"></div>
  235. </div>
  236. <div class="footer" role="contentinfo">
  237. &#169; Copyright SearXNG team.
  238. </div>
  239. </body>
  240. </html>