Hi guys,
Trying to get this to work. Here's what I put together:
- Code: Select all
Import time
ip = "10.0.1.20” ##Cameras_Pool_Equipment
timeout = 20
destination_var_id = 711613744
command = "/sbin/ping -c 1 -W {} {}".format(timeout, ip)
reply = subprocess.call(command, shell=True)
if reply == 0:
# successful ping
indigo.variable.updateValue(destination_var_id, value="true")
else:
# unsuccessful ping
indigo.variable.updateValue(destination_var_id, value="false")
When run in the action group dialog box python editor, it returns an "EOL while scanning string literal" error.
- Code: Select all
import subprocess
ip = "10
I opened the script in Xcode and the above is also highlighted in red.
this came back in the log:
- Code: Select all
Oct 5, 2019, 2:56:49 PM
Script Error Ping Cameras.py: compile() expected string without null bytes
Script Error Exception Traceback (most recent call shown last):
TypeError: compile() expected string without null bytes
Thoughts?
Also, I'd like to string together several pings in one script as below. Do you foresee any trouble with that? I did put in an "import time" so that I could space the pings out.
- Code: Select all
Import time
import subprocess
ip = "10.0.1.20” ##Cameras_Pool_Equipment
timeout = 20
destination_var_id = 711613744
command = "/sbin/ping -c 1 -W {} {}".format(timeout, ip)
reply = subprocess.call(command, shell=True)
if reply == 0:
# successful ping
indigo.variable.updateValue(destination_var_id, value="true")
else:
# unsuccessful ping
indigo.variable.updateValue(destination_var_id, value="false")
delay 2
ip = "10.0.1.21” #Fam Rm Patio Camera
timeout = 20
destination_var_id = 990844776
command = "/sbin/ping -c 1 -W {} {}".format(timeout, ip)
reply = subprocess.call(command, shell=True)
if reply == 0:
# successful ping
indigo.variable.updateValue(destination_var_id, value="true")
else:
# unsuccessful ping
indigo.variable.updateValue(destination_var_id, value="false")
delay 2
ip = "10.0.1.22” #Cameras2_Fam_Rm_Walkway
timeout = 20
destination_var_id = 145747591
command = "/sbin/ping -c 1 -W {} {}".format(timeout, ip)
reply = subprocess.call(command, shell=True)
if reply == 0:
# successful ping
indigo.variable.updateValue(destination_var_id, value="true")
else:
# unsuccessful ping
indigo.variable.updateValue(destination_var_id, value="false")