简体   繁体   中英

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. I have a shell script called ip.sh and i want to make a c++ program that runs it. So when I run the c++ program the script would run. Thanks in advance.

Use system() function, from <stdlib.h> :

system("myfile.sh");

Reference: system - cplusplus.com .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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