in Education by
I need help on looping all my list and print my list name. Currently, I have a few raspberry pi types and windows PC. I am trying to ping all my pi and windows and get the responses below are some of what I have tried question is how to loop, piserver, pi2b,pi2,pi3,pi4 and windows import platform plat = platform.system() piservers = {"10.10.10.115", "10.10.10.125", "10.10.10.135", "10.10.10.145", "10.10.10.165", "10.10.10.175", "10.10.10.185"} pi2b= {"10.10.10.111", "10.10.10.112", "10.10.10.113", "10.10.10.114"} pi2 = {"10.10.10.121", "10.10.10.122", "10.10.10.123", "10.10.10.124"} pi3 = {"10.10.10.131", "10.10.10.132", "10.10.10.133", "10.10.10.134"} pi4 = {"10.10.10.141", "10.10.10.142", "10.10.10.143", "10.10.10.144"} Windows = {"10.10.10.151", "10.10.10.152", "10.10.10.153", "10.10.10.154"} for vm in piservers : # Check for Windows and Linux Platforms if plat == "Windows": response = os.system("ping -n 1 " + vm) pass elif plat == "Linux": response = os.system("ping -c 1 -W 3 " + vm) pass #and then check the response... if response == 0: print ("***********************************") print(vm, 'is UP!') print ("***********************************") print ("\n") elif response == 2 or 256 or 512: print ("***********************************") print(vm, 'is DOWN and No response from Server!') print ("***********************************") print ("\n") else: print ("***********************************") print(vm, 'is DOWN!') print ("***********************************") print ("\n") Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
You can use the loop by using all the sets at once. for vm in piservers|pi2b|pi2|pi3|pi4|Windows: Learn data science with python course to improve your technical knowledge.

Related questions

0 votes
    I have the list like this where items are separated by ":". x=['john:42:engineer', 'michael:29:doctor' ... engineer 1 michael 29 doctor Select the correct answer from above options...
asked Jan 10, 2022 in Education by JackTerrance
0 votes
    In Javascript, I can do something like this let list = [1, 2, 3] let list2 = [4, 5, 6, ...list] And ... the += after declaring a list? Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    I'm looking for a decent implementation of the OPTICS algorithm in Python. I will use it to form density-based ... to that cluster. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd ... anyone help with that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I want to save files for each result from the loop. For example, I wrote the code but it only saves one file ... do I modify my code? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Here is my sample string: [true, {"name": "NameofItem", "amount": "1", "price": 100, "sellerName": " ... seem to make that work. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Hi, I am a relatively new programmer and my teacher gave us this problem to fix. Thing is, I have no idea ... wrong with this problem? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a big data frame. I want to replace float 1.0 and 0.0 with the true and false. My code: import pandas ... to do it in one line. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me why Python is better than R for Data Science? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me why Python is used in Data Science? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me whether Python is necessary for Data Science? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me whether Python is good for Data Science? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I am starting to work with python again after 8 years. I am trying to do the program with BeautifulSoup and an ... '__main__': main() Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I want to calculate a percentage, for each id, of True values from all rows of the id. Here an example ... df.num_true/df.num_col1_id Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    When I run pip3 install -r requirements.txt on the project I get this error message: pip._vendor.pkg_resources. ... on my machine. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
...