-1

I am trying to run a python script at ubuntu startup. The script(play.py) plays a youtube video in chrome browser.

import webbrowser
import time
import subprocess as sp

val = 0;
while(val <1):
    time.sleep(1)
    #webbrowser.open("https://www.youtube.com/watch?v=dO1rMeYnOmM")
    child = sp.Popen("google-chrome %s" % "https://www.youtube.com/watch?v=dO1rMeYnOmM", shell=True)
    val = val +1

To run this script at ubuntu startup I added the following entry in rc.local:

python /home/user_name/Desktop/python/play.py &

And changes the mode of play.py to 777. I also tried copying this script file to /etc/init.d. But still the script does not execute at system startup.

1 Answer 1

0

Try sudo /usr/bin/python /home/user_name/Desktop/python/play.py & instead.

Sign up to request clarification or add additional context in comments.

6 Comments

What is not working? The command or the script is not working upon loading? First ensure that the following command works fine. /usr/bin/python /home/user_name/Desktop/python/play.py &
sudo /usr/bin/python /home/user_name/Desktop/python/play.py & I added in rc.local but the browser is not opening at system startup.
We are back to square one. You still didn't answer whether the command only worked on terminal or not? First establish the command is working fine on terminal and then try to automate it. So again? What happened when you ran the command on terminal?
Everything in /etc/rc.local is run as root, there's no need to use sudo.
@triple.s add sheband on top of the script. #!/usr/bin/python
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.