我有下面的程序,我发现,并试图编辑,使其工作。我在python2.7中使用Kbuntu。运行脚本时出现以下错误:rm: cannot remove ‘Devices_Config_Pull.xls’: No such file or directory
rm: cannot remove ‘Devices_Config_Pull.zip’: No such file or directory
Traceback (most recent call last): File "config_pull.py", line 17,
in
connection = sys.argv[1] IndexError: list index out of rangeimport os,sys,string
sys.path.append('/home/user/python/lib/lib/python')
import pexpect
import xlwt
import credential
os.system('rm Devices_Config_Pull.xls') #This will remove previews created spreadsheet
os.system('rm Devices_Config_Pull.zip') #This will remove previews created zip
list_devices=open('list.txt').readlines() #This will read the list of devices that file is on the same location as the script
email, UID, passwd, enable = credential.cred() #This is a module that I created that will store all of credential
*connection = sys.argv[1]
connection = int(connection)*
### If the argument is 1 it will telnet into the devices if the argument is 2 it will ssh into the devices
if connection == 1:
tunnel = 'telnet '
conmess = 'telnet'
elif connection == 2:
tunnel = ('ssh -o StrictHostKeyChecking=no -l ' + UID + ' ')
conmess = 'SSH'
######## This for loop block. is the loop for telnet/ssh into the devices
wbk = xlwt.Workbook() #Create an excel workbook
font = xlwt.Font()
font.bold = True
#style = .XFStyle()
style.font = font < lines omitted>