Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok I have 2 linux machines, machine A and machine B. Machine A is a server running icecast audio server. Machine B is a desktop in the studio running BUTT(Broadcast Using This Tool) an x11 app that sends audio back to machine A.

Butt on machine B sometimes crashes(in fact any app we've tried and on windows too eventually crashes), killing the stream. However I have found out I configure icecast to run a stript whenever the source disconnects. I have private key authorization working for ssh between A and B. I have a script that if I run on B (via normal interactive ssh) will reluanch butt. What I don't know is how to write the script on A so it will run the script I have on B.

I have tried this:

ssh username_placeholder@B '/home/username_placeholder/'

running from A. But that seems to keep ssh alive. All I want to do is run it and hang up. looks like this:

killall butt
env DISPLAY=:0 butt&

This is because butt only runs in gui mode. and we do want to see the gui in the studio from time to time anyway. So how do I make it run that script and hangup, or is there an even better way to do this on A without trying to call the script on B. I want it to kill butt if it's still runing and then start it(remeber it still has to display on B, not A. and A is the computer that can know when the source on B hangs up.)

Computer A runs ubuntu server, and computer B runs linux mint in case anyone cares.

share|improve this question

You should consider using the screen command, it will allow you to do what you want with the added benefit of being able to reconnect to the shell at any point in time.


machine_a:> ssh machine_b


machine_b:> screen
machine_b:> run your script here


( Press Ctrl-a then ctrl-d to disconnect from the screen )


machine_b:> exit

LOGIN BACK INTO SERVER (at later date)

machine_a:>ssh machine_b


screen -list  (to show a list of all screen sessions that exist).

username@machine_b:~/> screen -list
There are screens on:
        30264.pts-5.machine_b  (Detached)
2 Sockets in /var/run/uscreens/S-username.


machine_b:> screen -dr 30264

At this stage you can see your script/command/shell exactly as you left it. Even if the command you ran was an xwindows application with display set to the remote server display.

To create the remote screen with your script running in the same way you are attempting to do using just ssh alone try this:

ssh -t username_placeholder@B 'screen -d -m /home/username_placeholder/'
share|improve this answer
Thank you for your answer, but I'm sorry I don't understand this very well. Am I supposed to run these commands for the setup process and then put the "screen -dr 30264" in my script to reconnect to that screen. will this kill the connection when I'm not using it? is 30264 a port I will need to open on my router protecting B? I still don't get what I put in the script on A that will run comands on B and hang up. Also Butt must show the gui on B, it seems like we are making some kind of virtual display here, is that what's going on? Thanks – UserZer0 Jan 29 '13 at 17:32
sorry for the delay... think of screen as running an entire shell as a background process that you can later reconnect to. ie. you can login remotely, create a screen, run commands or several and leave them running.... disconnect from that shell (drops you back to your original ssh shell) and you can safely exit that shell.. then at a later day you can ssh back into the remote machine and reconnect to the "screen" using the screen -list and screen -dr commands. – Matthew Aldous Feb 1 '13 at 6:04
Yeah don't run the screen command in your script... I've updated my answer to be more clear on how to use it. You could automate the whole thing with a single ssh command probably like... – Matthew Aldous Feb 1 '13 at 6:23
Try something like this: ssh -t username_placeholder@B 'screen -d -m /home/username_placeholder/' – Matthew Aldous Feb 1 '13 at 6:42

you must run your broadcast script from machine A with '-f' option of ssh:

ssh -f username_placeholder@B /home/username_placeholder/

this will automatically make '' go to the background.

The '' script itself then should look like this:

killall butt
DISPLAY=:0 butt
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .