0

When I start up this application called splashtop streamer by using python /opt/splashtop-streamer/SRStreamer.pyc at the prompt everything works fine.

However, when I add sh -c sleep 10; to the beginning of it, the application tells me it's already running and won't open the program. Why?

I'm trying to start the program 10 seconds into the boot of Ubuntu. When I use simply sleep 10; python /opt/splashtop-streamer/SRStreamer.pyc the application does not start. When I use sh -c sleep 10; python /opt/splashtop-streamer/SRStreamer.pyc the application comes up with the error message that another copy is already running, I click okay and it quits.

However it may be important to note that when I'm not booting up the sleep 10; python /opt/splashtop-streamer/SRStreamer.pyc command works fine.

7
  • At the beginning of what? Some script? Why sh -c sleep 10 and not simply sleep 10?
    – muru
    Oct 22, 2014 at 16:20
  • Answering question above.
    – Daniel
    Oct 22, 2014 at 16:49
  • have you tried python/opt/splashtop-streamer/SRStreamer.pyc -p 10 Oct 22, 2014 at 16:55
  • that just loads it instantaneously
    – Daniel
    Oct 22, 2014 at 16:56
  • Try dumping the command into a shell script, like so. chmod +x it, and run it at boot-time.
    – Kaz Wolfe
    Oct 22, 2014 at 16:59

3 Answers 3

1
+50

I recommend that you try dumping this into a script instead of a single command.

I have taken the liberty of making a script for you. Feel free to use it. If not, a template is below to help you create your own:

#!/bin/sh

sleep n; #Causes computer to wait n seconds before moving on to the next line
python /path/to/python/script.py;

This will work because it runs everything in a single sh process. Basically, it's the exact same as typing both of those commands, one after the other, into a SH prompt.

Once you have the script and have saved it to a safe place. (I like /home/$USER/.bin/run-this.sh, run this command in your terminal (any terminal):

chmod 755 /home/$USER/.bin/run-this.sh

Finally, add it to whatever boot-time solution you want, such as "Startup Items", init, rc.d, or whatever.

0

Also your sh -c sleep 10; should be change to sh -c 'sleep 10'; and then your command will be change to this:

sh -c 'sleep 10' && python /opt/Splashtop-streamer/SRStreamer.pyc

If you want to run your script with 10 seconds delay.

0

Since you're using Startup Applications for this, starting the program 10 seconds after login is what happens, so you could use an Upstart session job instead.

Create a .conf file in ~/.config/upstart (create the directory if needed), containing:

description "Splashtop Streamer Service"
start on desktop-start
stop on desktop-end

respwan

pre-start script
    sleep 10
end script

exec python /path/to/python/script.py

(Call it splashtop.conf, for example.)

The greatest advantage is that Upstart will respawn the program if it crashes, and you can control it using the start and stop initctl commands:

start splashtop
stop splashtop

You must log in to answer this question.

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