-1

I want to send a command line by MQTT from raspberry pi to my laptop. After search i found MQTT launcher 1 ,i want to send python simple_stream.py to run simple_stream script in windows ,but i don't know how to put the program and arguments of my command line ( python simple_stream.py) in launcher.conf file instead of the examples of author , this is launcher.conf file of author

logfile = 'logfile'
mqtt_broker = 'localhost'       # default: 'localhost'
mqtt_port = 1883                # default: 1883
mqtt_clientid = 'mqtt-launcher-1'
# mqtt_username = 'jane'
# mqtt_password = 'secret'

topiclist = {

    # topic                     payload value       program & arguments
    "sys/file"          :   {
                                'create'        :   [ '/usr/bin/touch', '/tmp/file.one' ],
                                'false'         :   [ '/bin/rm', '-f', '/tmp/file.one'    ],
                                'info'          :   [ '/bin/ls', '-l', '/tmp/file.one' ],
                            },
    "prog/pwd"          :   {
                                None            :   [ 'pwd' ],
                            },
    "dev/1"             :   {
                                None            :   [ 'ls', '-l', '/' ],
                            },
    "dev/2"             :   {
                                None            :   [ "/bin/echo", "111", "*", "@!@", "222", "@!@", "333" ],
                            },
}

can you please help me

hardillb
  • 54,545
  • 11
  • 67
  • 105
  • Update the question with what you have already tried. Also there are Paho clients for Java, Javascript, Go, Python..... Which one are you using? – hardillb Apr 26 '17 at 20:28
  • i am using python ,i wanna try this https://github.com/jpmens/mqtt-launcher , but i don't know how to use it – Balsam Qassem Apr 27 '17 at 09:16

1 Answers1

0

Add a line to the sys/file, right after info, that says the following: 'launch' : [ '/usr/bin/python', 'simple_stream.py' ], This way, when you send the payload 'launch' (without quotes) to the topic sys/file, it will execute the desired python script. Please adjust with the path of your python executable (in linux: 'which python' will tell you the path). Hope this helps.

Moreno
  • 526
  • 2
  • 14