Hi All

I want to execute my custom python scripts in rpc shell script. However,
they are not executed. Could someone help me on this?

*Example Python script:*
*===================*
root@OpenWrt:~# cat hello.py
from subprocess import call

call(["touch", "/root/ap1", "down"])

print "{'status':'True'}"

*Shell script:*
*==========*
root@OpenWrt:~# cat /usr/libexec/rpcd/foo
#!/bin/sh
. /usr/share/libubox/jshn.sh
case "$1" in
        list)
                echo '{ "bar": { "arg1": true, "arg2": 32, "arg3": "str" },
"toto": { } }'
        ;;
        call)
                case "$2" in
                        bar)
                                # read the arguments
                                read input;

                                # optionally log the call
                                logger -t "foo" "call" "$2" "$input"

                                *python /root/hello.py*

                                # return json object or an array
                                echo '{ "hello": "world" }'
                        ;;
                        toto)
                                # return json object or an array
                                echo '[ "item1", "item2", "item3" ]'
                        ;;
                esac
        ;;
esac
root@OpenWrt:~#
root@OpenWrt:~# ubus call -S foo bar '{"arg1": true }'
{"hello":"world"}
root@OpenWrt:~#
root@OpenWrt:~# ls              ==========> Files are not created.
Math      foo       hello.py
root@OpenWrt:~#

Best Regards
Phani
_______________________________________________
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users

Reply via email to