Saturday, February 24, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1270  / 2 Years ago, wed, october 27, 2021, 4:37:28

When I issue the command sudo fio myjog | tee mylog in a terminal window,
I can save the fio log into the mylog file.



But if I issue the command sudo gnome-terminal -x sudo fio myjog | tee mylog, the mylog file will be created without any text inside.



How to capture a printed log from gnome-terminal -x ?


More From » command-line

 Answers
1

Each command run in the command line is, in order:




  • interpreted by the shell;

  • interpreted by the executable;



In this case | makes the shell interpret sudo gnome-terminal -x sudo fio myjog | tee mylog as two commands piped to each other (sudo gnome-terminal -x sudo fio myjog and tee mylog, the first one piped to the second one).



The result of this is that the output of sudo gnome-terminal -x sudo fio myjog is piped to tee mylog; since gnome-terminal doesn't output anything, mylog is empty.



Use the -e option to pass the command to be executed as an argument;



Commands passed through the -e options are executed in sh;



In this case, since you want to use a pipe, which is a bash (and other shells) feature, you'll need to explicitly run the command in bash (on a side note: you don't need sudo to run gnome-terminal if you're going to use sudo in the argument to the -x / -e options):



gnome-terminal -e "bash -c "sudo fio myjog | tee mylog""

[#18092] Thursday, October 28, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rryble

Total Points: 489
Total Questions: 121
Total Answers: 119

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;