0
import tkinter as tk
import tkinter.filedialog


def tester():

    def script (TL1_Command):
        print ("%s\r" %(TL1_Command) )

    root = tk.Tk()
    root.attributes("-topmost", True) 
    root.withdraw()
    file = tkinter.filedialog.askopenfilename()
    
    with open(file,"r") as fh:
        for line in fh:
            IP,UID,PWD,NE = line.split(",")
##            print (IP)
##            print (PWD)
##            print (UID)
##            print (NE)
            script("ED-TL1GW:%s:SHELF-%s:TAG6:::GNE=%s,RNE=%s;"
                   %(IP,PWD, UID, NE) )

if __name__ == "__main__":
    tester()

This is to get variables for the main program.

Text pad has:

IP1,UID1,PWD1,NE_Name1
IP2,UID2,PWD2,NE_Name2
IP3,UID3,PWD3,NE_Name3
IP4,UID4,PWD4,NE_Name4

Output is:

ED-TL1GW:IP1:SHELF-PWD1:TAG6:::GNE=UID1,RNE=NE_Name1
;
ED-TL1GW:IP2:SHELF-PWD2:TAG6:::GNE=UID2,RNE=NE_Name2
;
ED-TL1GW:IP3:SHELF-PWD3:TAG6:::GNE=UID3,RNE=NE_Name3
;
ED-TL1GW:IP4:SHELF-PWD4:TAG6:::GNE=UID4,RNE=NE_Name4;

How do I remove the new line and have the semicolon after the command like NE_Name4 has?

martineau
  • 119,623
  • 25
  • 170
  • 301
James
  • 69
  • 7

0 Answers0