I have below script where I am getting error after executing. Can any help in resolving errors.
#!/usr/bin/env python
import os
servers = os.system("cat /root/pydev/serv") # =====> /root/pydev/serv has list of servers.
for serv in servers:
if serv == "server01":
print(serv)
else:
print("No Serv found")
breakOutput error:-Error:server01
server02
server03
Traceback (most recent call last):
File "./loops.py", line 9, in <module>
for serv in servers:
TypeError: 'int' object is not iterable

. The given code change worked well and gave anticipated output. Can you recommended any good books or resource for learning Python for Linux/Unix Admins so that I can integrate commands in code and also for reports generation and other etc... features. I am primarily Bash and Korn user and want to switch to Python for my code development. Please advise.