I try to do like below:

#!/usr/bin/env sh


ffmpeg -i "$name" -acodec copy output.mp4 | mate-terminal

I want to see the results in a newly opened terminal, but of course it doesn't wrok like that.

  • Thanks for answer. But when I run this command, the newly opened terminal is closed immediately. – user386273 Jan 6 '20 at 20:01

This is what's required :

mate-terminal -e "bash -c \"ffmpeg -i $name -acodec copy output.mp4;read -p'Press Enter to quit'\""

Explain: What we want is to run two commands (maybe others as well)

ffmpeg -i $name -acodec copy output.mp4
read -p'Press Enter to quit'

By chaining them together with bash -c

bash -c "ffmpeg -i $name -acodec copy output.mp4;read -p'Press Enter to quit'"

To put it in the context of mate-terminal, we need to escape both double quotes:

bash -c \"ffmpeg -i $name -acodec copy output.mp4;read -p'Press Enter to quit'\"

mate-terminal -e accept a single argument which gives :

mate-terminal -e "bash -c \"ffmpeg -i $name -acodec copy output.mp4;read -p'Press Enter to quit'\""
  • Thank you! This did the trick. But we assumed that the default terminal emulator is mate-terminal. What can we do if user use another emulator and we don't know? – user386273 Jan 6 '20 at 20:39
  • User should tell what (s)he uses. – Philippe Jan 6 '20 at 20:46
  • Also this is one command. There is no way to add the whole commands in " ". Is there another way to do it? – user386273 Jan 6 '20 at 20:46
  • There are two commands above, ffmpeg and read – Philippe Jan 6 '20 at 20:47
  • I mean entire commands in a script. There will be several usages and these commads also use quotes. Isn't there be a conflict with the qutoes for bash -c? – user386273 Jan 6 '20 at 20:53

To be sure, a terminal session is not quite the same as a shell. A shell is a command interpreter, a terminal session opens a new virtual terminal that runs a shell [command interpreter]. You could also view a terminal window is an optional wrapper around a shell that allows you to see output and potentially interact with the shell. The window normally closes when the shell it is running has terminated.

In this case, you may want an interactive shell, which may execute a command, and then returns a prompt so that you can give it new commands. For dash, it would be the -i parameter to use.

Alternatively, you can ask the terminal emulator to keep the window open, even when the shell has finished executing the command and has terminated (for not being interactive). For example, xterm uses the option -hold to keep the window open.

So to apply this using the xterm example, you will need a command like this:

xterm -hold -e ffmpeg -i "$name" -acodec copy output.mp4

Note that -e must be the last argument for xterm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy