import subprocess
import ipaddress
import pygsheets
from subprocess import Popen, PIPE
from pprint import pprint
from googleapiclient import discovery
#def append_table(start='A1', end=None, values=None, dimension='ROWS',
overwrite=False)
gc = pygsheets.authorize(service_file="testProj.json")
source_spreadsheet =
gc.open_by_key("1Mc1RbfPZIbxmCiqlRJt_AWJVasrGqA7iLmUkuHHL3tw")
wks = source_spreadsheet.sheet1
network = ipaddress.ip_network('10.70.60.0/23')
for i in network.hosts():
i=str(i)
toping = Popen(['ping', '-c', '3', i], stdout=PIPE)
output=toping.communicate()[0]
hostalive = toping.returncode
if hostalive == 0:
print (i, "Pings")
else:
print (i, "Doesn't ping")
I was able to read from the file, I just want to figure out how I can write to it. For example column A will list all the IP's in the subnet and column B will print out if the IP pings or doesn't