简体   繁体   English

通过xCode运行终端和命令

[英]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.

相关问题 是否可以在终端上以较慢的速度运行命令行程序? - Is it possible to run a command line program slower, on the terminal? 通过C中的字符串运行命令 - Run command through string in C 无法通过终端运行应用程序,但应用程序在XCode中正常运行 - Unable to Run application via Terminal but application working fine in XCode C / XCode:sh:./child:没有这样的文件或目录。 命令在终端中运行,但不在XCode中运行 - C/XCode: sh: ./child: No such file or directory. Command runs in terminal but not XCode 无法在 VTE GTK4 Fake Terminal 中运行 shell 命令 - Can't run shell command in VTE GTK4 Fake Terminal 如何使用fork()和execlp()在不同的终端上运行命令 - how to run a command on different terminal using fork() and execlp() 有没有办法让 vim 在另一个终端 window 中运行“make”命令? - Is there a way to make vim run the “make” command in another terminal window? 无法通过Android终端运行.out文件 - Impossible to run a.out file through Android terminal 如何在从终端执行C程序的同时运行终端命令 - How do I run a terminal command at the same time as executing a C program from terminal 钩在终端上。 我可以在终端中运行命令之前调用方法吗? - Hooks on terminal. Can I call a method before a command is run in the terminal?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM