View Single Post
Old 11-01-2019, 02:41 AM
JoseLuis JoseLuis is offline
Registered User
Join Date: Oct 2019
Posts: 2
Create filename with a variable python

Hell everyone. This is my first post hope I am doing it right. I am trying to read from Cisco devices the hostname and then open a txt file with the name of the host. This is the code I am using.
The crt version I am using is 7.2.1. Python is version 3.7.2

import os
def main():
	hostname = crt.Screen.ReadString("#",10)
	filename = os.path.join("C:/Users/" + str(hostname) + ".txt")
	fp = open(filename, "wb+")
	crt.Screen.Synchronous = False
The code above works fine if I substitute str(hostname) by any string. What am I doing wrong.
Many thanks for your support.

Last edited by berdmann; 11-01-2019 at 11:51 AM.
Reply With Quote