LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2011, 08:03 PM   #1
safari8
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Rep: Reputation: 0
Exclamation how to run mplayer in background with command line ?


sometimes i just want to stay in console and not start kde. But i do not know how to play music backgroundly. Could anybody help ?Thank you
 
Old 05-05-2011, 08:16 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835
Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:
mplayer *.ogg &
 
1 members found this post helpful.
Old 05-06-2011, 11:07 AM   #3
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Fedora FC23, Raspbian, Ubuntu Precise via Chrome/Crouton
Posts: 356

Rep: Reputation: 43
Quote:
Originally Posted by TobiSGD View Post
Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:
mplayer *.ogg &
Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:
[1]+  Stopped                 mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:
mplayer *.ogg </dev/null >/dev/null 2>&1 &
 
3 members found this post helpful.
Old 05-06-2011, 03:00 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,133
Blog Entries: 2

Rep: Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835Reputation: 4835
Quote:
Originally Posted by pwalden View Post
Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:
[1]+  Stopped                 mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:
mplayer *.ogg </dev/null >/dev/null 2>&1 &
Thanks for the correction, I just assumed that you can send mplayer to background like you do with most other commandline programs. Good to know that doesn't work, and also how the command should look like.
 
1 members found this post helpful.
Old 05-07-2011, 05:01 AM   #5
safari8
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by TobiSGD View Post
Just start the player as would you do normally, but add an ampersand at the end of the command, like this:
Code:
mplayer *.ogg &
thank you,it really helps.it works with amp
 
Old 05-07-2011, 05:04 AM   #6
safari8
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by pwalden View Post
Actually that will not work as mplayer reads from standard in and writes to standard out and error. When running mplayer in the background as suggested above, you will get a message:
Code:
[1]+  Stopped                 mplayer *.ogg
Which means that mplayer halts until it can get access to the in/out file descriptors. typing fg will restart mplayer, but it will run in the foreground. You can avoid this problem by redirection in/out to null.
Code:
mplayer *.ogg </dev/null >/dev/null 2>&1 &
wow! that's really amazing
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change background via command line verbose Linux - General 10 07-19-2012 10:31 AM
How to enter graphical mode (run level 5) command line (run lenel 3) edmondgyampoh Linux - Newbie 3 05-15-2009 06:33 PM
Perl: Running Command line apps in background and capturing output s0l1dsnak3123 Programming 8 03-28-2008 01:24 PM
Changing KDE background from command line goodyboy Linux - Software 1 02-06-2007 04:11 PM
run command in background using C syberdave Programming 3 04-03-2004 06:43 AM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration