![]() |
#1 |
Member
![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 540
Join Date: Aug 2010
Device: Kindle 3
|
Running a command from KUAL using pipes not as expected
Hi
[TL/DR] Running a command from KUAL using pipes not as expected I have a PI 3B+ running openwrt and four Amazon Kindle Paperwhite 1 Wi-Fi, I have v2.7.23-g9f3694a of KUAL installed, with USB networking. I can successfully transfer data between machines, by ssh into each machine and running scripts with the scripts and applications using netcat (aka nc). I am trying to convert to an KUAL extension so finish the project and release. However I must be doing something wrong with piping. Minimal working example from SSH - not KUAL On a separate machine (running OpenWRT) Code:
root@OpenWrt:~# mkfifo /tmp/example.pipe root@OpenWrt:~# cat /tmp/example.pipe | netcat -l -vvv -p 5001 & root@OpenWrt:~# Listening on any address 5001 ssh onto Kindle Code:
[root@kindle root]# nc 192.168.1.126 5001 | tee -i Code:
root@OpenWrt:~# mkfifo /tmp/example.pipe root@OpenWrt:~# cat /tmp/example.pipe | netcat -l -vvv -p 5001 & root@OpenWrt:~# Listening on any address 5001 Connection from 192.168.1.105:47765 root@OpenWrt:~# echo "hi" >/tmp/example.pipe root@OpenWrt:~# Code:
[root@kindle root]# nc 192.168.1.126 5001 | tee -i hi Minimal working example Using KUAL Now again using KUAL, using extension as:- Code:
[root@kindle root]# cat /mnt/us/extensions/OkMonitor/menu.json { "items": [ { "name": "NC Examples", "priority": -998, "items": [ { "name": "nc example 1", "action": "nc 192.168.1.126 5001 | tee -i ", "internal": "Example" } ] } ] } [root@kindle root]# Code:
root@OpenWrt:~# mkfifo /tmp/example.pipe root@OpenWrt:~# cat /tmp/example.pipe | netcat -l -vvv -p 5001 & root@OpenWrt:~# Listening on any address 5001 Code:
root@OpenWrt:~# mkfifo /tmp/example.pipe root@OpenWrt:~# cat /tmp/example.pipe | netcat -l -vvv -p 5001 & root@OpenWrt:~# Listening on any address 5001 Connection from 192.168.1.105:59820 Total received bytes: 0 Total sent bytes: 0 I need nc to pipe to a different compiled application, but using tee as the application in this examples. Things I have tried:-
Any pointers would be great. Or any ideas how I can debug further. ![]() Thanks, Brendan |
![]() |
![]() |
![]() |
#2 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
There's massive I/O redirections involved in KUAL, so I'm not suite sure this'll ever work, period.
EDIT: (This is what actually ends up being passed to ash -c after being wrapped in an actual shell script). That said, you definitely should not be doing that straight from an action. Do that in a shell script, and run *that* instead. That should allow you to deal more sanely with any I/O redirection constraints, and possibly background more sanely so you don't block the UI, because I also don't remember how that's dealt with, but that was never the intended usecase ![]() EDIT²: Well, the action is force-backgrounded anyway, see above edit ;p. Last edited by NiLuJe; 11-22-2020 at 12:46 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Member
![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 540
Join Date: Aug 2010
Device: Kindle 3
|
Quote:
Hey KUAL is so good, wanted to give it a try. Any pointers in making a customers "Book?" .az2 like KUAL ? Any pointer on the source for KUAL so I can see if I can try and debug further ? |
|
![]() |
![]() |
![]() |
#4 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
See a couple of EDITs in my original answer
![]() I would highly, highly, highy recommend *NOT* trying to deal with the Kindlet (deprecated) / Booklet (private, highly obfuscated) APIs yourself, unless you have severe masochistic tendencies ![]() As you might find out, even rebuilding KUAL itself requires a shitload of hoop-jumping, and full dumps from scarily old FW versions (or not, I may be mixing things up with CM. Kindlets are hell. Java is pain.). I do know that you won't be able to use anything newer than a JDK 8, as they all dropped support for the crappy old language version we need. EDIT: Okay, for KUAL, you actually "just" need two or three old dumps, one for the KDK1 API, one for the KDK2 API, and one for the Booklet API. ;p. See the readme in the lib folder, which might not be entirely up-to-date. Fun example (and I stopped caring a good long while ago, so I probably can't build current CollectionsManager versions). Code:
┌─(niluje@illyria:pts/4)───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(~)─┐ └─(0.13:26%:18:51:%)── du -h -d1 ~/Kindle/Kindlet-Dev ──(Sun, Nov 22)─┘ 30M /home/niluje/Kindle/Kindlet-Dev/fw-520 26M /home/niluje/Kindle/Kindlet-Dev/fw-538 68M /home/niluje/Kindle/Kindlet-Dev/JDK-1.4.2_19 26M /home/niluje/Kindle/Kindlet-Dev/fw-534 15M /home/niluje/Kindle/Kindlet-Dev/Decompilers 19M /home/niluje/Kindle/Kindlet-Dev/fw-5371 37M /home/niluje/Kindle/Kindlet-Dev/fw-5442 20M /home/niluje/Kindle/Kindlet-Dev/fw-532 26M /home/niluje/Kindle/Kindlet-Dev/fw-539 40M /home/niluje/Kindle/Kindlet-Dev/fw-592 20M /home/niluje/Kindle/Kindlet-Dev/fw-512 26M /home/niluje/Kindle/Kindlet-Dev/fw-536 26M /home/niluje/Kindle/Kindlet-Dev/fw-530 26M /home/niluje/Kindle/Kindlet-Dev/fw-531 19M /home/niluje/Kindle/Kindlet-Dev/fw-5372 30M /home/niluje/Kindle/Kindlet-Dev/fw-544 26M /home/niluje/Kindle/Kindlet-Dev/fw-535 288K /home/niluje/Kindle/Kindlet-Dev/fw-411 268K /home/niluje/Kindle/Kindlet-Dev/fw-258 26M /home/niluje/Kindle/Kindlet-Dev/fw-5381 31M /home/niluje/Kindle/Kindlet-Dev/fw-5432 26M /home/niluje/Kindle/Kindlet-Dev/fw-533 31M /home/niluje/Kindle/Kindlet-Dev/fw-5431 37M /home/niluje/Kindle/Kindlet-Dev/fw-5451 20M /home/niluje/Kindle/Kindlet-Dev/fw-5321 30M /home/niluje/Kindle/Kindlet-Dev/fw-542 30M /home/niluje/Kindle/Kindlet-Dev/fw-5421 31M /home/niluje/Kindle/Kindlet-Dev/fw-545 19M /home/niluje/Kindle/Kindlet-Dev/fw-537 30M /home/niluje/Kindle/Kindlet-Dev/fw-5441 31M /home/niluje/Kindle/Kindlet-Dev/fw-543 4.0K /home/niluje/Kindle/Kindlet-Dev/MAIN 34M /home/niluje/Kindle/Kindlet-Dev/fw-540 46M /home/niluje/Kindle/Kindlet-Dev/fw-565 882M /home/niluje/Kindle/Kindlet-Dev Last edited by NiLuJe; 11-22-2020 at 01:21 PM. |
![]() |
![]() |
![]() |
#5 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
You could also just try strace'ing netcat and/or tee (log to a file), to see what actually makes it die.
(Wild guess: something throws an EPIPE somewhere, somehow). Last edited by NiLuJe; 11-22-2020 at 01:20 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Member
![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 540
Join Date: Aug 2010
Device: Kindle 3
|
Wow - rabbit hole.....
I think I may have an <ugly> way forward. Automating screen sessions (Which is ironic)! |
![]() |
![]() |
![]() |
#7 |
Member
![]() ![]() ![]() ![]() ![]() ![]() Posts: 24
Karma: 540
Join Date: Aug 2010
Device: Kindle 3
|
From the openwrt machine
Code:
root@OpenWrt:~# cat ./test.sh rm /tmp/example.pipe mkfifo /tmp/example.pipe cat /tmp/example.pipe | netcat -l -vvv -p 5001 & sleep 1 screen -dmS default_session -t screen_name screen -S default_session -p screen_name -X stuff 'ssh root@192.168.1.105 "nc 192.168.1.126 5001 | tee -i" \r' sleep 1 echo "hi" >/tmp/example.pipe echo "world" >/tmp/example.pipe root@OpenWrt:~# /bin/ash test.sh Listening on any address 5001 Connection from 192.168.1.105:37688 root@OpenWrt:~# screen -S default_session -p screen_name -X kill root@OpenWrt:~# Total received bytes: 0 Total sent bytes: 9 Thanks for the replies. Back to tidying up and finding the next snag. |
![]() |
![]() |
![]() |
#8 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 52
Karma: 616590
Join Date: Feb 2019
Device: K4 KT4 PW4 PW5
|
Actually rebuilding KUAL is not too hard, the necessary libs are easy to dump straight from the device. I built a stripped down version that just launches Koreader as KUAL was being too slow for me
![]() https://github.com/yparitcher/KUAL_Booklet |
![]() |
![]() |
![]() |
#9 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
The Booklet variant has the advantage of only needing a single source, since it gets rid of the two (older) APIs, which means you can actually get those from an Amazon update package, no digging up old devices/backups necessary
![]() Unfortunately, the OP appears to be on a K3, so, KDK1 ![]() |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issue by running a plugin in the command line interface | RbnJrg | Plugins | 4 | 06-13-2018 11:27 AM |
How to install KUAL and mods on KOA running 5.9.2.0.1? | tigrisg | Kindle Developer's Corner | 5 | 01-10-2018 10:21 AM |
Install Kual and Mods on KT3 Running 539.2.0.1 | seba20xx | Kindle Developer's Corner | 1 | 12-22-2017 08:00 PM |
How to convert linux apps for running in kual? | Aeris | Kindle Developer's Corner | 8 | 09-19-2013 09:37 AM |
Running from command line in Leopard | iain_benson | Calibre | 1 | 06-05-2009 10:49 AM |