To clarify the question: I need to open a terminal window, execute a C program (which takes input from a file) and save its output to a file.
澄清问题:我需要打开一个终端窗口,执行一个C程序(从文件中获取输入)并将其输出保存到文件中。
I know that if I do "./program < input.txt > output.txt", I'll get what I want.
我知道如果我做“./program
For some reason, if I do "gnome-terminal -e ./program < input.txt > output.txt", the program opens on a different terminal window, but doesn't take the input from input.txt nor saves the output to the output.txt file.
出于某种原因,如果我执行“gnome-terminal -e ./program
What am I doing wrong?
我究竟做错了什么?
2 个解决方案
#1
0
You need bash to redirect input and output in new gnome terminal.
你需要bash来重定向新的gnome终端中的输入和输出。
gnome-terminal -e 'bash -c "./program < input.txt > output.txt"'
#2
1
Try gnome-terminal -e "./program < input.txt > output.txt"
试试gnome-terminal -e“./program
#1
0
You need bash to redirect input and output in new gnome terminal.
你需要bash来重定向新的gnome终端中的输入和输出。
gnome-terminal -e 'bash -c "./program < input.txt > output.txt"'
#2
1
Try gnome-terminal -e "./program < input.txt > output.txt"
试试gnome-terminal -e“./program