I'm using Python's telnetlib.write() function for quite some time without issues, but in this case the command that I want to send does nothing. While the same command sent through SecureCRT works fine.
Here's more or less what I have:
import telnetlib
tn = telnetlib.Telnet(HOST)
tn.read_until('login: ')
tn.write(user + '\n')
if pswrd:
tn.read_until('Password: ')
tn.write(pswrd + '\n')
tn.write('echo "" > /path/to/file.log' + '\n')
tn.write('exit\n')
tn.close()
What this should do is clear the contents of file.log, but the file remains the same. Why is this happening? If it's worth mentioning, the telnet server is running SunOS. Thanks!