-->
Page 1 of 1

Uploading a file to a NodeMCU ESP8266 telnet server

PostPosted: Sun Nov 22, 2015 5:49 pm
by Blue
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.

Re: Uploading a file to a NodeMCU ESP8266 telnet server

PostPosted: Sun Jul 24, 2016 2:33 pm
by Blue
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

Re: Uploading a file to a NodeMCU ESP8266 telnet server

PostPosted: Mon Apr 02, 2018 9:28 am
by shariq_azim
Hi,
Thank you for the awesome work .
But i failed to understand if by uploading a file you mean uploading code into nodeMCU(like OTA) or anything different?

Shariq

Re: Uploading a file to a NodeMCU ESP8266 telnet server

PostPosted: Mon Apr 02, 2018 9:42 am
by shariq_azim
Hi,
Are you uploading a lua file (like firmware update)or the codes of .ino/.bin files into the nodeMCU(like OTA update)?