python telnet and put the message in a particular log file
hi I am coding the python script to login telnet and it has to write log file to op.txt the absolute path is /netperf/mntpt/array1/home/prg_use/op.txt the python code ptlog.py import getpass import sys import telnetlib import time host ="12.12.1.123" user ="user_name" passwd ="telnet_password" tn = telnetlib.Telnet(host) tn.read_until("login: ") tn.write(user + "\n") tn.read_until("Password: ") tn.write(passwd + "\n") tn.write("touch op.txt \n") time.sleep(5) tn.write("lr \n") str_all=tn.read_until("$") #f=open("/netperf/mntpt/array1/home/prg_use/op.txt", "w") f=open("op.txt", "w") f.write(str