LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Opening VLC with the terminal line so the terminal will go back to normal (https://www.linuxquestions.org/questions/linux-newbie-8/opening-vlc-with-the-terminal-line-so-the-terminal-will-go-back-to-normal-697116/)

baldurpet 01-13-2009 08:11 PM

Opening VLC with the terminal line so the terminal will go back to normal
 
I've been pottering around the command line for some time, so I have some knowledge of it but I'm still a newbie.

The 'problem' is that I want to experiment with opening a movie in VLC using the command line. I typed in vlc and there it was, so I selected my movie like this:
Code:

vlc movies/legally \obtained \movie/movie.avi
and that works just fine; VLC pops up and starts playing movie.avi, and I also found out that you could start VLC without an interface if you type in cvlc so that's cool. But the problem is that when it starts playing the terminal doesn't go back the normal command prompt baldur@baldur-main:~$ (yes I don't care that you know my computer's name) but instead the VLC keeps on running in the terminal while the movie plays.

I've seem this with many other programs and this guy says that it's possible to make the prompt return by annexing it with &. But when I do that nothing changes!

I was once programming in MatLab on my Linux computer, and it had to be opened through with the terminal and if I closed the terminal MatLab would close as well! I can't believe that you have to have two open terminals if you want to use MatLab and VLC (from the command line) at the same time!

lurko 01-13-2009 08:51 PM

So you used the command $vlc movies/legally \obtained \movie/movie.avi & ? Try hitting enter in the terminal after VLC starts, if the first line of output after you run that is something like "[1] 29803" then the process has been backgrounded and hitting enter should produce a fresh prompt. Any output VLC produces will go into that terminal though, possibly obscuring the prompt again.

Most desktop's have a Run dialog you can popup, it's usually Alt+F2 but could be something else. That way you don't need a terminal open at all, but tab completion may or may not function.

Another option would be to use screen, if you close your GUI terminal window, screen will detach your CLI session, itself running in the background, and any gui apps you've started from the CLI will keep runing. In the completely unscientific test I just ran, you can background a process from inside screen, exit the terminal(inside screen) which you started the process from (not just detach the screen), and the process will keep running. Doing the same from a regular terminal without screen kills the backgrounded process. I don't understand what the difference is though so hopefully someone can enlighten us.

baldurpet 01-13-2009 09:48 PM

Quote:

Originally Posted by lurko (Post 3407710)
So you used the command $vlc movies/legally \obtained \movie/movie.avi & ? Try hitting enter in the terminal after VLC starts, if the first line of output after you run that is something like "[1] 29803" then the process has been backgrounded and hitting enter should produce a fresh prompt.

God damn.. pushing enter twice did the trick. So & does make programs run in the background.

How ever I didn't get any process ID. Ok, it's late and I'm a little daft. I looked for a PID when I was terminating the program. Yeah, I did get the PID [1] 7742. :)

Quote:

Originally Posted by lurko (Post 3407710)
Most desktop's have a Run dialog you can popup, it's usually Alt+F2 but could be something else. That way you don't need a terminal open at all, but tab completion may or may not function.

Ah yes, I know about Alt+F2, but I just wanted to learn how to do it this way ;) it's never bad to have a few ways of doing the same thing (also, now I better understand the & thing, that is going to be very helpful).

I couldn't really understand that last part you said :tisk: it's not nice to talk about such complicated things to a noob

lurko 01-14-2009 10:57 AM

You're correct, it is always nice to have options.

screen is like a window manager, but for terminals.
Quote:

Originally Posted by http://en.wikipedia.org/wiki/GNU_Screen
GNU Screen can be thought of as a text version of graphical window managers, or as a way of putting virtual terminals into any login session. It is a wrapper that allows multiple text programs to run at the same time, and provides features that allow the user to use the programs within a single interface productively.

Persistence
Similar to VNC, GNU Screen allows the user to start applications from one computer, and then reconnect from a different computer and continue using the same application without having to restart it. This makes migration between locations like work and home simple. Screen provides terminal-agnostic functionality so that users can disconnect and reconnect using different terminal types, allowing applications to continue running without being aware of the change in terminals.
Multiple windows
Multiple terminal sessions can be created, each of which usually runs a single application. The windows are numbered, and the user can use the keyboard to switch between them. Some GUI terminal emulators provide tabs or otherwise similar functionality to this. Each window has its own scroll-back buffer, so that output is captured even when the window isn't actively displayed, and that history can be saved even when migrating to another computer. Windows can be split-screened. While some text applications have this functionality built in, Screen allows any application to be horizontally split-screened alongside any number of other applications.
Session Sharing
Screen allows multiple computers to connect to the same session at once, allowing collaboration between multiple users. The same computer can also be used to make multiple simultaneous connections, providing alternative functionality to screen-splitting, particularly for computers with multiple monitors.

So basically, screen provides a way to background (detach in screen parlance) the entire terminal, and the program(s) running in it, and to reattch it later. And your screen session can include any number(? probably there's some limit, but I'm not aware of it) of terminal interfaces. It rocks. Say you've got some time-consuming process running in a terminal. If you run it inside screen, and say, your Xserver/desktop crashes majorly and dumps you onto the console, your time consuming process will still be running inside a detached screen session. You can reattach it right there on the console, or you can restart X and run an Xterm or something and reattach screen from there.

some Screen howtos:
http://jmcpherson.org/screen.html
http://khaoohs.wordpress.com/2006/08...nd-quickstart/
http://www.linuxdynasty.org/screen-howto-part-1.html
http://www.linuxdynasty.org/screen-howto-part-2.html

edit: what I confused you with before, I was saying that if you use an ampersand to background a process, from inside screen, even after you exit screen (this would be just like quiting your Xterm) the backgrounded process keeps running, unlike exiting a non-screen'd terminal you've backgrounded a process from (which causes the backgrounded process to also quit for some reason I cannot fathom). here's hoping this didn't just exacerbate the confusion. The howtos should help make screen's function clearer, then if you like you can try backgrounding a program from inside screen and then exiting screen to see the result.


All times are GMT -5. The time now is 03:52 AM.