I just want to share with you a simple bash script to upload a file to an ESP8266 when a telnet server is run there. It helps me when I'm too lazy to physically access my device and still wants to upload an updated script.
The target has the same file name as the source file.
It works fine with the telnet server shown as an example on the NodeMCU project page (https://github.com/nodemcu/nodemcu-firmware).
#!/bin/sh
delay=0.5
file=`basename $1`
(k=1;echo "file.remove(\"$file\")";sleep $delay;echo "file.open(\"$file\",\"w\")";sleep $delay; while read line;do echo "print($k);file.writeline([[$line]])"; k=$((k+1)); sleep $delay; done < $1;echo "file.close()")|ncat -v $2 23
The first parameter is the file to be uploaded and the second parameter is a telnet server name/address.