Parking txt and scoring



  • There's a txt file in every line of the name of the Post Office. The txt file needs to be evaporated, downloaded into the dictionary and then put each value in the type template over the cycle

    config user local
        edit "ФИО1"
            set type ldap
            set email-to "ПОЧТА1"
            set ldap-server "LDAPS"
        next
    end
    config user local
        edit " ФИО2"
            set type ldap
            set email-to "ПОЧТА2"
            set ldap-server "LDAPS"
        next
    end
    

    And so on.

    There'll be a ready file on the exit with a long list. Example of password file

    Pupkin Vladimir pulkin@mail.ru
    Ivanov Ivan ivanov@mail.ru
    

    Specially departed from the name and mail of two signs.



  • Try this code:

    res = ""
    

    with open("file.txt") as file:
    lines = file.readlines()
    lines = [line.rstrip() for line in lines]

    for line in lines:
        components = line.split()
    
        res += f'fconfig user local\n    edit "{" ".join(components[:2])}"\n        set type ldap\n        set email-to "{components[2]}"\n        set ldap-server "LDAPS"\n    next\nend\n'
    

    print(res)


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2