Search code examples
pythontwisted

How to send and receive data on the same line in twisted python?


I am simulating an SFTP server using twisted python. i want to send the "ftp>" before getting an input from the user on the same line. i have tried

basic.LineOnlyReceiver.sendLine(self, msg)

but it gets the input on a different line how to make it such as in the image?

example of the output I want to simulate ftp> any command that the user write should be here on the same line ftp> pwd


Solution

  • inside reply method that we override, use one of them based on the output you want

     def reply(self, key):
              
         self.sendLine(msg) # if you want to send data on separate lines
         self.transport.write(b'ftp> ') # if you want to send data without'/n' delimiter