This is my firs time posting and i am going to be as thorough as possible
my boss has requested that i make a python program on a raspberry pi (running raspbian), the parameters he requested are these:
the program should ping various network devices every 5 minutes
if the ping succeeds, send a signal to one of the GPIO pins
if the ping fails, send a signal to one of the GPIO pins
that signal will be sent to another device which will initiate an alarm.
I have come up with something based on internet searches, but i keep running into road blocks, and have a lot of questions...
here is the code i have:
=========================================
right now, i am getting this error, "if response= == 0 name "response" is not defined."
is it smart to run this based on a .txt file? i thought it would be good in case we want to add or remove IPs.
i am also wondering how to then take that output of the ping and make it trigger a high or low signal on the pin.
Sorry if this post broke all the rules... thanks in advance
my boss has requested that i make a python program on a raspberry pi (running raspbian), the parameters he requested are these:
the program should ping various network devices every 5 minutes
if the ping succeeds, send a signal to one of the GPIO pins
if the ping fails, send a signal to one of the GPIO pins
that signal will be sent to another device which will initiate an alarm.
I have come up with something based on internet searches, but i keep running into road blocks, and have a lot of questions...
here is the code i have:
=========================================
import ipaddress import socket import os with open('test_list.txt') as fname: sw = fname.read().splitlines() for s in sw: response = os.system('ping -n 2' + s) if response == 0: print(s, 'is up!') else: print(s, 'is Down!')========================================
right now, i am getting this error, "if response= == 0 name "response" is not defined."
is it smart to run this based on a .txt file? i thought it would be good in case we want to add or remove IPs.
i am also wondering how to then take that output of the ping and make it trigger a high or low signal on the pin.
Sorry if this post broke all the rules... thanks in advance