Jun-24-2022, 11:29 AM
Hello everybody,
I have a script which should do something (to make an example, I let it create a folder). Therefore I defined a function which does just that:
I have a script which should do something (to make an example, I let it create a folder). Therefore I defined a function which does just that:
def folder(): path = os.getcwd() newPath = path+"/tmp" os.mkdir(newPath)But I only want my function to be executed when at least one of my clients are online. The ip addresses are defined in a json file:
[ { "Name": "Client 1", "ip": "192.168.1.2" }, { "Name": "Client 2", "ip": "192.168.1.3" } ]Now I want to define a new function which checks all ip addresses. The question I have is, how do I get the ips from my json and ping them one after another to check if at least one of them is online and if they are execute my folder-function? This is all I have so far:
def ipCheck(): f = open('clients.json') data = json.load(f) for i in data: print(i) f.close()