<div dir="ltr">
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Hi All</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">I want to execute my custom python scripts in rpc shell script. However, they are not executed. Could someone help me on this?</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><b>Example Python script:</b><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><b>===================</b></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><font face="monospace, monospace">root@OpenWrt:~# cat hello.py</font></div><div><font face="monospace, monospace">from subprocess import call</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">call(["touch", "/root/ap1", "down"])</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">print "{'status':'True'}"</font></div></div><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><b>Shell script:</b></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><b>==========</b></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div><font face="monospace, monospace">root@OpenWrt:~# cat /usr/libexec/rpcd/foo</font></div><div><font face="monospace, monospace">#!/bin/sh</font></div><div><font face="monospace, monospace">. /usr/share/libubox/jshn.sh</font></div><div><font face="monospace, monospace">case "$1" in</font></div><div><font face="monospace, monospace"> list)</font></div><div><font face="monospace, monospace"> echo '{ "bar": { "arg1": true, "arg2": 32, "arg3": "str" }, "toto": { } }'</font></div><div><font face="monospace, monospace"> ;;</font></div><div><font face="monospace, monospace"> call)</font></div><div><font face="monospace, monospace"> case "$2" in</font></div><div><font face="monospace, monospace"> bar)</font></div><div><font face="monospace, monospace"> # read the arguments</font></div><div><font face="monospace, monospace"> read input;</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> # optionally log the call</font></div><div><font face="monospace, monospace"> logger -t "foo" "call" "$2" "$input"</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> <span> </span><b>python /root/hello.py</b></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"> # return json object or an array</font></div><div><font face="monospace, monospace"> echo '{ "hello": "world" }'</font></div><div><font face="monospace, monospace"> ;;</font></div><div><font face="monospace, monospace"> toto)</font></div><div><font face="monospace, monospace"> # return json object or an array</font></div><div><font face="monospace, monospace"> echo '[ "item1", "item2", "item3" ]'</font></div><div><font face="monospace, monospace"> ;;</font></div><div><font face="monospace, monospace"> esac</font></div><div><font face="monospace, monospace"> ;;</font></div><div><font face="monospace, monospace">esac</font></div><div><font face="monospace, monospace">root@OpenWrt:~#</font></div><div><span style="font-family:monospace,monospace">root@OpenWrt:~# ubus call -S foo bar '{"arg1": true }'</span><br></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace"><div>{"hello":"world"}</div><div>root@OpenWrt:~#</div><div>root@OpenWrt:~# ls ==========> Files are not created.<br></div><div>Math foo hello.py</div><div>root@OpenWrt:~#</div></font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">Best Regards</div>
Phani</div>