Hello
jimmo ,
thank you for your answer.
jimmo wrote:
How does your automation work? How does it invoke webrepl_client.py?
My program is written in Pascal. To invoke this command, I use a library allowing to launch any external program by providing the name of the corresponding executable and the execution parameters if there are any.
Here is what my procedure looks like:
Code: Select all
Process := TProcessEX.Create(nil);
try
with Process do
begin
Executable := './webrepl_client.py';
Parameters.Clear;
Parameters.Delimiter := ' ';
Parameters.DelimitedText := '-p password 192.168.1.30 < <(echo "D")';
Options := [poNoConsole, poWaitOnExit, poUsePipes];
Execute;
ShowMessage(Process.OutputString); // for testing during debugging
end;
finally
Process.Free;
end;
At runtime, "ShowMessage(Process.OutputString);" returns me :
Code: Select all
webrepl_client.py - remote shell using MicroPython WebREPL protocol
Arguments:
[-p password] [-dbg] [-r] <host> - remote shell (to <host>:8266)
Examples:
webrepl_client.py 192.168.4.1
webrepl_client.py -p abcd 192.168.4.1
webrepl_client.py -p abcd -r 192.168.4.1 < <(sleep 1 && echo "...")
Special command control sequences:
line with single characters
'A' .. 'E' - use when CTRL-A .. CTRL-E needed
just "exit" - end shell
which is in fact the help that is displayed in the console when you invoke "webrepl_client.py" without parameters.
I don't think this procedure is at fault because I use it frequently without any problem, and that in this particular case, when invoking "webrepl_cli.py" (not to be confused with "webrepl_client.py") :
Code: Select all
Process := TProcessEX.Create(nil);
try
with Processus do
begin
Executable := './webrepl_cli.py';
Parameters.Clear;
Parameters.Delimiter := ' ';
Parameters.DelimitedText := '-p password data.js 192.168.1.30:/html/data.js';
Options := [poNoConsole, poWaitOnExit, poUsePipes];
Execute;
ShowMessage(Process.OutputString); // for testing during debugging
end;
finally
Process.Free;
end;
"ShowMessage(Process.OutputString);" returns :
Code: Select all
op:put, host:192.168.1.30, port:8266, passwd:password.
data.js -> /html/data.js
Remote WebREPL version: (1, 13, 0)
Sent 0 of 482 bytes
Sent 482 of 482 bytes
which informs me that everything went well.
jimmo wrote:
I'm surprised that `echo "D"` works -- that would send a D (i.e 0x44). You need to send 0x04, which would be `echo -ne "\x04"`
For the command, I used the example provided in the github repository
https://github.com/Hermann-SW/webrepl :
Code: Select all
$ ./webrepl_client.py -p abcd -r 192.168.4.1 < <(sleep 1 && echo "E" && cat sc.py && echo -e "D\nc(7)\nexit")
From a terminal, the following four commands work:
Code: Select all
./webrepl_client.py -p htro 192.168.1.30 < <(echo "D")
./webrepl_client.py -p htro 192.168.1.30 < <(echo -e "D")
./webrepl_client.py -p htro 192.168.1.30 < <(echo -ne "\x04") // your suggestion
./webrepl_client.py -p htro 192.168.1.30 < <(echo -e "D\nc(7)\nexit")
None of them work when I invoke them from my program.
Here's where I'm at now.
Friendly,
naute