title: IP scan then do certain job and play MP3 only once
body: <p>I have the following  code here. What I want to do is I want to script to scan my ip address then do certain job. </p>
  
  <p>My problem is the MP3 is always repeating every 30 seconds even if I did not turn off my phone WIFI which is carrying the IP of the hostname. </p>
  
  <p>I'd like the MP3 to only play once after the script found the IP but the scan will continue scanning. </p>
  
  <p>Is that possible? Any help will be very much appreciated</p>
  
  <pre><code>#!/usr/bin/env python
  import os, sys
  import sched, time
  s = sched.scheduler(time.time, time.sleep)
  def do_something(sc):
          import os
          hostname = "192.168.254.102" #example
          response = os.system("ping -c 1 " + hostname)
          if response == 0:
                  print(hostname, 'is up!')
                  os.system("sudo python ../aquarium/nightlight_on.py 1")
                  os.system("omxplayer -o local ../music/jarvis_on.mp3 1")
          else:
                  print(hostname, 'is down!')
                  os.system("sudo python ../aquarium/nightlight_off.py 1")
          sc.enter(160, 1, do_something, (sc,))
  s.enter(30, 1, do_something, (s,))
  s.run()
  </code></pre>