Chat about current Lua tools and IDEs

User avatar
By Blue
#34719 Hi,

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).

Code: Select all#!/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.
User avatar
By Blue
#51433 Removing some bugs

Code: Select all#!/bin/bash
if [ -z "$1$2" ]; then
  echo "Usage: upload.sh [file] [esp8266 telnet server ip address]"
  exit 1
fi
delay=0.5
file=`basename $1`
(k=1;echo "file.remove(\"$file\")";sleep $delay;echo "file.open(\"$file\",\"w\")";sleep $delay; while IFS='' read -r line;do echo "print($k);file.writeline([[""${line//]/] }""]])"; k=$((k+1)); sleep $delay; done < $1;echo "file.close()")|ncat -v $2 23