Need help - passing a variable

19 views
Skip to first unread message

TJ Sullivan

unread,
Dec 18, 2015, 4:03:31 PM12/18/15
to MQTT
Have a very simple python script with a shell command calling mosquitto_pub.  Can not get it to pass the value of "test", which is just a simple integer.

test=1+n
n=n+1
os.system("mosquitto_pub -d -t test/topic -m test")

when i open a seperate window and subscribe to test/topic I only receive the word test not its integer value.  How do define the variable test??

Thanks in advance....

Nicholas O'Leary

unread,
Dec 18, 2015, 4:07:11 PM12/18/15
to mq...@googlegroups.com
You need to append the variable on to the end of the command string:

 test=1+n
 n=n+1
 os.system("mosquitto_pub -d -t test/topic -m "+test)

Nick

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages