简体   繁体   English

如何通过 cpp 程序运行 shell 脚本?

[英]How do I run a shell script thorugh a cpp program?

I just wanted to know if i could make a c++ program make the shell script run.我只是想知道我是否可以制作一个 C++ 程序来运行 shell 脚本。 I have a shell script called ip.sh and i want to make a c++ program that runs it.我有一个名为 ip.sh 的 shell 脚本,我想制作一个运行它的 C++ 程序。 So when I run the c++ program the script would run.因此,当我运行 C++ 程序时,脚本将运行。 Thanks in advance.提前致谢。

Use system() function, from <stdlib.h> :使用system()函数,来自<stdlib.h>

system("myfile.sh");

Reference: system - cplusplus.com .参考: system -cplusplus.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM