Edit file through telnet possible?
Is it possible to edit files using Telnet?
@jmarcelino Oh yes, I forgot the connect command of rshell. You can also edit through that tool, with
After running rshell just do:
connect telnet your IP address
and you should then see the LoPy filesystem on /flash
Note that you the board must be in the REPL, if it's running a script you must terminate it
@misterlisty I'm correcting my notes:
Used this little script for step a)
import sys def getfile(path): print("Send file contents line by line, finish with Crl+C-Enter.") with open(path, "w") as f: while 1: try: l = sys.stdin.readline() except KeyboardInterrupt: break f.write(l) print(".", end="")
It does not echo, but you have to end it with an error.
b) use the command
and then paste it from Teraterm (alt-v). In teraterm's special settings, use a long value for delay between lines for paste, like 100m. That way, I was able to upload a ~900 line python file (the editor).
You might be able to upload a file in two steps
a) Upload a script which received data & puts it into a file:
def newfile(path): print("Type file contents line by line, finish with EOF (Ctrl+D).") with open(path, "w") as f: while 1: try: l = input() except EOFError: break f.write(l) f.write("\n")
Push Ctrl-E, paste the few lines about, and push Ctrl-D. Then you have the function newfile in RAM.
b) You can use that to upload another file. But that must be done slow. TeraTerm has an ASCII-Upload feature, which sends files line-by-line with an delay between the lines. You could use that to upload the changed files.
I have an editor which works on the board. It is here: https://github.com/robert-hh/Micropython-Editor. I normally have it in flash. The editor is too large for devices w/o PSRAM to be executed from RAM. But you may be able to send your file the way sketched above.
Edit: Just tried my suggestion myself. Works not really well. Uploading the newfile() function works, but TeraTerm does not work well in an attempt to send that file, or the LoPy stalls, at least if it's more than a few lines of code.
i forgot to open ftp port on the router on remote site.
@misterlisty How did you disable ftp, and can you enable it again though repl?
I have deployed some devices in the filed and have only enabled telnet instaead of telnet/ftp...how can i edit a file using REPL until i get access to them again.
It’s possible but very cumbersome, you’d have to do it using Python on the REPL.
Why not use FTP instead which is also available?