Steven Scott Steven Scott - 1 month ago 21
Bash Question

Embedding shell scripts in another language?

Is it possible to embed shell scripts into a higher-level programming language, for example, C++?
How would one go about doing that? For example, do you just place the script somewhere in the C++ code and the compiler is able to understand the script and the C++ code too?

mtk mtk
Answer

Can you embed shell scripts into higher-level languages ? Answer: Yes

You can always use the system api calls to execute any command and hence any shell script.

In C++, you can call the system function, like

#include<cstdlib>
system("myShellScrit.sh");