Get the App
SLTechnology News&Howtos  ›  Network Security  › 

How to detect the host IP in batch and generate the result into excel file table

Shulou Source: shulou.com Published: 2022-05-31 17:09:06 10月02日 Update

How to batch test the host IP and generate the results into excel file table, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

This is an extension of the previous script, adding the generation of excel tables

# coding=gbk

Import os

Import sys

Import xlwt

Wk = xlwt.Workbook (encoding = 'utf-8')

Sheet1 = wk.add_sheet ("IP62", cell_overwrite_ok=True)

Style = xlwt.XFStyle ()

Sheet1.write (0,014 IP address', style)

Sheet1.write (0pen 1, 'status', style)

X = y = 0

For ip in range (1255):

Res = os.system ('ping-n 1-w 1' + sys.argv [1] + str (ip))

If res = = 0:

Print (sys.argv [1] + str (ip) + 'up')

Sheet1.write (ip,0,sys.argv [1] + str (ip))

Sheet1.write (ip,1,'up')

X + = 1

Else:

Print (sys.argv [1] + str (ip) + 'down')

Sheet1.write (ip,0,sys.argv [1] + str (ip))

Sheet1.write (ip,1,'down')

Y + = 1

Print ('total up ip is' + str (x))

Print ('total down ip is' + str (y))

Sheet1.write (ip+1,0,'total up ip is'+ str (x))

Sheet1.write (ip+2,0,'total down ip is'+ str (y))

Wk.save ('ip.xls')

After reading the above, do you know how to batch test the host IP and generate the results into an excel file table? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Tables generators hosts files results tests contents methods more problems helpless for this reason reason address this skills status articles experience scripts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Docker Shulou Information MariaDB