Skip to content

xdevdoc otdmDriverProto web cmd sub process

Bartlomiej Ceglik edited this page Feb 21, 2023 · 4 revisions

otdmDriverWebCmdSubProcess.py indepth explenation / documentation - coder edition

otdmDriverWebCmdSubProcess

To index

Table of Contents

otdmDriverWebCmdSubProcess

otdmDriverWebCmdSubProcess Objects

class otdmDriverWebCmdSubProcess(otdmSubProc, otdmDriverProto)

to access it use: $ otdmTools.py -webCmdSubProcess ......

Web cmd sub precess driverProto brings bash and pips to a game of oiyshTerminal and otdm-tools. It's to run somethin externaly on different instance of otdm-tools or localy but event starting it can be a web page javascript funcion invoque. Or as a element in any of your dayly tasks.

Brings bash layer to web page or Node-red.

For me updating system repository

Extra args for this driver

-stdout [string] if set then result of command returns to stdout -> -oFile of subrocess two not only mqtt

$ curl 'http://localhost:1880/yss/?otdmQ:\{"webCmdSubProcess":"\[ls,/tmp,|,grep,313\]","pH":"66","stdhttp":"yes"\}'

to get ls with 313 words in it, from host localhost. Return [array] of elements. Last element is [int] = -1 (end of process)

Example

$ otdmTools.py -pH "pH84946_91997" -oFile "/tmp/ee.json" -webCmdSubProcess \
'[cat,/data/data/com.termux/files/home/.otdm/config.json,|,jq,"keys in conf: "+keys[],-r]'

Return on mqtt subP/pH84946_91997/line

0:keys in conf: grafana
1:keys in conf: mqtt
2:keys in conf: mysql
3:keys in conf: node-red
4:keys in conf: otdm

This will can file in bash pipe it to jq parse it in jq add prefix. Result is send to mqtt at subP/pH84946_91997

$ otdmTools.py -webCmdSubProcess "[mplayer,/myMusic.mp3]" -pH "pH93419_" -oFile "--"

This will start mqtt topic

  • subP/pH93419_/status - will public starting or done
  • subP/pH93419_/line - will give line by line from command
  • subP/pH93419_/in - it's a stdin of command so in this example sending p will pause :)

Check: helper on javascript site mDoCmd - documentation

or

# to file result not the subprocess status, cmd running in shell
$ otdmTools.py -pH "pH84" -oFile "/tmp/res11.json" -webCmdSubProcess '[sh,-c,echo "abc" | grep "ab333"; echo $?]' -stdout 1

keyWord

keyWord webCmdSubProcess

Clone this wiki locally