I want to save bitstream data from a device connected to the ethernet port of my laptop.The ip address of the device is 192.168.2.100, telnet port 23. I have to read and store the data using python sockets.Can anyone please help me for this?
Asked
Active
Viewed 121 times
0
-
You want to know how to read a text file? – KSFT Mar 01 '15 at 14:59
1 Answers
0
You can take a look at these answers regarding connecting a socket and reading from it. Then it's a simple matter of opening a file and writing to it:
open("output.dat", "a").write(data)
The first parameter to 'open' is the file name, the second parameter is the mode (e.g. write, append, et cetera); the method called within the returned object 'write' has a parameter of the data you wish to write. As one statement, the file closes automatically. Otherwise you will want to close it with close()
to ensure the cache is flushed to the disk, and the file handle is discarded properly.