Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script won't run at boot
#1
Hi,

The code below which speaks a wellcome msg if there's an internet connection, runs manually but not at boot through crontab.

Where did I go wrong?
TIA

#!/usr/local/bin/python3

from subprocess import call
from time import sleep

domain = ('www.google.com')

def _call():
    call(['espeak "Welcome John" 2>/dev/null'], shell=True)

def ping(host):
    ret = call(['ping', '-c', '3', '-W', '5', host], stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
    return ret

if __name__ == "__main__":
    p = 1
    while p == 1:
      p = ping(domain)
      if(p == 0):
        _call()
      sleep(.3)
Reply


Messages In This Thread
Script won't run at boot - by ebolisa - Mar-21-2020, 06:00 PM
RE: Script won't run at boot - by Larz60+ - Mar-21-2020, 06:03 PM
RE: Script won't run at boot - by ndc85430 - Mar-21-2020, 06:04 PM
RE: Script won't run at boot - by ebolisa - Mar-21-2020, 06:20 PM
RE: Script won't run at boot - by ndc85430 - Mar-21-2020, 06:22 PM
RE: Script won't run at boot - by ebolisa - Mar-21-2020, 06:28 PM
RE: Script won't run at boot - by ebolisa - Mar-21-2020, 08:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Running from boot Murray6301 5 3,105 Nov-07-2020, 05:41 PM
Last Post: snippsat
  Console crash after boot. friendlymegalomaniac 1 2,590 Apr-07-2018, 05:44 PM
Last Post: wavic
  find my system is single boot or dual boot using python Sachin_d 2 2,820 Nov-02-2017, 09:29 AM
Last Post: Sachin_d

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020