> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/ar/mqalat-mtamqh/52-using-luatex-to-run-tools-and-utilities-installed-on-overleaf-s-servers.md).

# استخدام LuaTeX لتشغيل الأدوات والبرامج المساعدة المثبتة على خوادم Overleaf

## خوادم Overleaf: تشغيل البرامج وتنفيذها

تقوم خوادم Overleaf القوية بترجمة مشروعك داخل صندوق عزل قائم على [تقنية حاويات لينكس من Docker](https://www.docker.com/). يحصل كل مشروع على صندوق العزل الخاص به، مما يضمن أن أي شيفرة ننفذها كجزء من ترجمة المشروع تكون معزولة عن المشاريع الأخرى—وهذه هي الطبقة الأولى من عدة طبقات من الحماية التي نستخدمها لترجمة المشاريع بأمان. بالنسبة لمستخدمي TeX، يعني هذا أنه يمكنك الوصول بأمان إلى الأدوات والوسائل المساعدة الموجودة على خوادمنا واستخدامها—ولكن كيف؟ في هذه التدوينة القصيرة نوضح كيفية استخدام سكربت Lua (عبر LuaTeX) لتنفيذ برنامج خارجي والتقاط أي نص كان سيُخرج عادةً إلى نافذة طرفية. على سبيل المثال، افترض أنك تريد تحويل بعض ملفات DVI إلى SVG باستخدام `dvisvgm` الأداة، لكنك لا تتذكر خيارات سطر الأوامر المختلفة؟ ألن يكون من الجيد تنضيد قائمة بها بسرعة لتنعش ذاكرتك؟ إذا كان الأمر كذلك، فتابع القراءة—أما إذا كنت تفضل رؤية ذلك عمليًا، فانتقل إلى هذا [مثال مشروع في المعرض](https://www.overleaf.com/latex/examples/using-luatex-to-run-software-installed-on-overleafs-servers/nnvfvnfhzwsy) لترى كيف يتم ذلك.

![لقطة شاشة لمشروع على Overleaf](/files/88bfa0f89ae3277dcd0f085f438c96b6f125b8c5)

### استخدام LuaTeX لتشغيل برنامج خارجي عبر سكربت Lua

بما أن LuaTeX يضم لغة البرمجة Lua مدمجة داخل محرك TeX، يصبح من السهل جدًا كتابة سكربت قصير لا ينفذ برنامجًا خارجيًا فحسب، بل يلتقط أيضًا أي نص كان ذلك البرنامج سيخرجه إلى نافذة طرفية ويحفظه في ملف. وبعد حفظ ذلك النص في ملف يمكنك استخدام `verbatim` الحزمة لاستيراده إلى مستند TeX الرئيسي. فيما يلي الشيفرة كاملة اللازمة للقيام بذلك باستخدام LuaTeX:

```latex

\documentclass{article}
\usepackage{verbatim}
\begin{document}
\directlua{
function runcommand(cmd)
local fout = assert(io.popen(cmd, 'r'))
local str = assert(fout:read('*a'))
fout:close()
return str
end

local sout=runcommand("dvisvgm --help")
local marg = assert(io.open("command.txt","w"))
marg:write(sout)
marg:flush()
marg:close()
}
\verbatiminput{command.txt}
\end{document}
```

السطر الأساسي في الشيفرة أعلاه هو `local sout=runcommand("dvisvgm --help")` الذي ينفذ `dvisvgm` مع خيار سطر الأوامر `--help` لأمر `dvisvgm` بعرض جميع خيارات سطر الأوامر الخاصة به. يتم التقاط نص المساعدة وحفظه في ملف نصي يُسمى `command.txt`. بعد أن تنتهي شيفرة Lua داخل `\directlua{...}` من التنفيذ، يُدرج محتوى `command.txt` في مستند TeX الرئيسي باستخدام `\verbatiminput{command.txt}`. من المهم أن تُدرج أي نصوص ملتقطة على أنها مادة حرفية لأن المحارف مثل `$, #, \, _, ^` إلخ. قد تكون موجودة داخل النص المستورد.

لا تتردد في تعديل الشيفرة في `runcommand("dvisvgm --help")` واستكشاف تشغيل برامج أخرى—مثل GhostScript—أو أي برنامج من برامج TeX Live قد ترغب في استخدامه.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/ar/mqalat-mtamqh/52-using-luatex-to-run-tools-and-utilities-installed-on-overleaf-s-servers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
