How to start a C program and send input from a file using the "gnome-terminal" command?

StackOverflow https://stackoverflow.com/questions/18772306

  •  28-06-2022
  •  | 
  •  

سؤال

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.

I know that if I do "./program < input.txt > output.txt", I'll get what I want.

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.

What am I doing wrong?

هل كانت مفيدة؟

المحلول

You need bash to redirect input and output in new gnome terminal.

    gnome-terminal -e 'bash -c "./program < input.txt > output.txt"'

نصائح أخرى

Try gnome-terminal -e "./program < input.txt > output.txt"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top