[英]Run terminal and command through xCode
I basically want to write a code that will open terminal on my Mac and run a program. 我基本上想编写一个在Mac上打开终端并运行程序的代码。 I copied the Terminal application where the executable for the code is.
我将终端应用程序复制到了代码的可执行文件所在的位置。 Then I tried:
然后我尝试了:
int system(const char *command);
system("open -a Terminal.app --args gnuplot");
This will open terminal but not nothing more (does not initialize GNUplot). 这将打开终端,但仅此而已(不初始化GNUplot)。
Thank you! 谢谢!
OP here. 在这里操作。 I found out the best way to go about this is instead make a .sh file.
我发现解决此问题的最佳方法是制作一个.sh文件。 Within that, I run my code that outputs a data file, and then, within that same .sh file, I run GNUplot how I'd like.
在其中,我运行我的代码以输出数据文件,然后在相同的.sh文件中,按我的意愿运行GNUplot。 It works much better and it automated from terminal instead of trying to make a C code to run terminal.
它工作得更好,并且可以从终端自动执行,而不必尝试使C代码运行终端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.