Problem with exec node displaying log file

Hello,
I want to display log file on dashboard by using template node from this reference.
It's working well until the file containing with special char like ( β, µ).

I'm using "cat" command with exec node. I've tested cat command with ssh terminal, and working well.

I've attached the flow as reference;

[{"id":"ee54b1e6.a6319","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8a44fe73.1d3ed","type":"file","z":"ee54b1e6.a6319","name":"","filename":"/home/pi/Arduino_SMS/SMS_Log.txt","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":790,"y":260,"wires":[[]]},{"id":"53d37865.f89f98","type":"debug","z":"ee54b1e6.a6319","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":440,"wires":[]},{"id":"f0b40890.bc9308","type":"ui_template","z":"ee54b1e6.a6319","group":"d32df258.5ad34","name":"","order":1,"width":"6","height":"4","format":"<style>\n    #mylog {\n        min-height: 450px;\n        max-height: 500px;\n        padding: 0;\n        white-space: pre;\n    }\n</style>\n\n<div id=\"mylog\" ng-bind=\"msg.payload\" contenteditable=\"true\">\n    <!-- file contents will go here -->\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":720,"y":320,"wires":[[]]},{"id":"6c51653.7a1679c","type":"inject","z":"ee54b1e6.a6319","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"non-Printable char µ end of string","payloadType":"str","x":290,"y":320,"wires":[["f0b40890.bc9308"]]},{"id":"98db0c3e.0058d","type":"exec","z":"ee54b1e6.a6319","command":"cat /home/pi/Arduino_SMS/SMS_Log.txt","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"cat","x":370,"y":460,"wires":[["53d37865.f89f98","f0b40890.bc9308"],[],[]]},{"id":"a7a8cd7f.9a72d","type":"ui_button","z":"ee54b1e6.a6319","name":"Read Cat File","group":"d32df258.5ad34","order":3,"width":"2","height":"1","passthru":false,"label":"Cat File","tooltip":"","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":200,"y":460,"wires":[["98db0c3e.0058d"]]},{"id":"85bf123c.0f21","type":"ui_button","z":"ee54b1e6.a6319","name":"Clear File","group":"d32df258.5ad34","order":3,"width":"2","height":"1","passthru":false,"label":"Clear File","tooltip":"","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":420,"y":260,"wires":[["f0b40890.bc9308"]]},{"id":"d32df258.5ad34","type":"ui_group","name":"Default","tab":"ca552dc7.8db33","order":1,"disp":true,"width":"6","collapse":false},{"id":"ca552dc7.8db33","type":"ui_tab","name":"Test","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I think the problem is caused by exec node.

cat command displaying special char


SMS_Log.txt (523 Bytes)

Any suggestion is greatly appreciated.

Aung

Couple of things you could try.

First would be checking the lang and charset that your browser is getting for the page.

<!doctype html><html lang="en"><head>
    <meta charset="utf-8">

Second would be to replace those characters with their matching HMTL entities before display.

Thank for fast reply.
Do you think that template node problem?
Please check this flow below:

[{"id":"ee54b1e6.a6319","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8a44fe73.1d3ed","type":"file","z":"ee54b1e6.a6319","name":"","filename":"/home/pi/Arduino_SMS/SMS_Log.txt","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":790,"y":260,"wires":[[]]},{"id":"53d37865.f89f98","type":"debug","z":"ee54b1e6.a6319","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":440,"wires":[]},{"id":"f0b40890.bc9308","type":"ui_template","z":"ee54b1e6.a6319","group":"d32df258.5ad34","name":"","order":1,"width":"6","height":"4","format":"<style>\n    #mylog {\n        min-height: 450px;\n        max-height: 500px;\n        padding: 0;\n        white-space: pre;\n    }\n</style>\n\n<div id=\"mylog\" ng-bind=\"msg.payload\" contenteditable=\"true\">\n    <!-- file contents will go here -->\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":720,"y":320,"wires":[["53d37865.f89f98"]]},{"id":"6c51653.7a1679c","type":"inject","z":"ee54b1e6.a6319","name":"A","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"non-Printable char µ end of string","payloadType":"str","x":290,"y":320,"wires":[["f0b40890.bc9308"]]},{"id":"98db0c3e.0058d","type":"exec","z":"ee54b1e6.a6319","command":"cat /home/pi/Arduino_SMS/SMS_Log.txt","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"cat","x":370,"y":460,"wires":[["53d37865.f89f98","f0b40890.bc9308"],[],[]]},{"id":"a7a8cd7f.9a72d","type":"ui_button","z":"ee54b1e6.a6319","name":"Read Cat File","group":"d32df258.5ad34","order":3,"width":"2","height":"1","passthru":false,"label":"Cat File","tooltip":"","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":200,"y":460,"wires":[["98db0c3e.0058d"]]},{"id":"85bf123c.0f21","type":"ui_button","z":"ee54b1e6.a6319","name":"Clear File","group":"d32df258.5ad34","order":3,"width":"2","height":"1","passthru":false,"label":"Clear File","tooltip":"","color":"","bgcolor":"","icon":"","payload":" ","payloadType":"str","topic":"","x":420,"y":260,"wires":[["f0b40890.bc9308"]]},{"id":"61d0a142.a5e8","type":"inject","z":"ee54b1e6.a6319","name":"B","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"non-Printable char µ end of string","payloadType":"str","x":230,"y":400,"wires":[["98db0c3e.0058d"]]},{"id":"d32df258.5ad34","type":"ui_group","name":"Default","tab":"ca552dc7.8db33","order":1,"disp":true,"width":"6","collapse":false},{"id":"ca552dc7.8db33","type":"ui_tab","name":"Test","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hello,
Is there anyone can point out this problem? I'm still not able to use "exec" node for that application.

Any suggestion is greatly appreciated.

Aung

Is the empty string coming direct from the exec node? Wire the debug just to the exec node to check. If it is coming from the exec node then how can it be the template node that is at fault, as you are sending it an empty string.
It is confusing that you have put an error message into inject A as I assumed that it is that error that you are trying to fix.
Connect debug nodes to all three outputs of the exec nodes (and not the template), Configure them to show Complete Message (that is important) give the debug nodes names so you can see which is which in the output and click B. See if there are any errors in the debug output.

why would you use cat in a exec node when you can use the read file node?

Yes, it can come. Actually, I'm doing a project involving reading SMS data from USB GSM dongle. That SMS data is saved to text file, then read back by exec node. Sometimes, telecom company sends some promotion SMS and that SMS includes special characters.

I'm trying to make simulation of injection of the special char to exec node.

The reason is I want to read the SMS data in chronological order meaning that "cat" is for present to past time and "tac" for reverse order.

Now, I use regex to filter the special char as temporary solution.

Thanks for suggestion,
Aung

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.