3

I'm using sox to play a sound on our local server (ubuntu 16.04). I run play myfile.mp3 through ssh.

However, that sound only plays if I'm logged in on that local server. Any idea how to achieve this even if nobody is logged in?

Thx

[EDIT] the goal is not to log in, do something then log out and keep it running. The goal is to play that sound on the local server over ssh without having to log in on the local server's GUI at all.

muru
  • 207,228
Sbe88
  • 133

3 Answers3

1

Try your command with sudo

sudo mpv myfile.mp3 and it's actually starts playing on speaker

It's very likely a problem with permissions e.g. if you are running Pulseaudio. With the right permissions, you can play sounds on the remote machine via ssh just fine.

We need to update the permissions of pulseaudio ( atleast in my case ) because it's work fine with sudo

Hope it's helps.

HeRo
  • 11
1

You can use the program screen on the server (https://help.ubuntu.com/community/Screen, http://www.gnu.org/software/screen/).

$ sudo apt-get install screen # if not installed on the server

Login via SSH and start a screen

$ screen -S my_sound_bash 

start you music. You can use Ctrl+A+D to leave the current screen session and you can logout. The music should still play.

You can login again using SSH and with

$ screen -r my_sound_bash 

you should get your running player back.

dessert
  • 40,956
Max
  • 194
1

To start the player directly with a oneliner, do e.g.:

ssh user@host 'cvlc music/Ratatat/LP4'   # VLC opens whole directories
ssh user@host 'play music/Ratatat/LP4/*' # SoX don't

If you're in a ssh session and want a process to remain running after you exited, you can use disown to disconnect the process from the shell that runs it:

$ ssh user@host
$ cvlc music/Nick_McKaig & disown
$ exit

That's the easy way, however you're not able to return to the session as it's possible with screen (see Max' answer) or tmux.

dessert
  • 40,956