# Execute Python2 script with payload

**URL:** <https://discourse.nodered.org/t/execute-python2-script-with-payload/54255>\
**Category:** General\
**Created:** [25 November 2021 08:53 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255 "2021-11-25T08:53:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [25 November 2021 08:53 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/1 "2021-11-25T08:53:03Z")

</div>

Until now I have executed Python scripts using an exec node in this way:

> python -u /home/pi/....../script.py

and everything works great.  
I have a situation now where I need to execute a Python2 script with a payload. In terminal I execute it in this way and it works fine: python2 ./sendsigfox1.py 123abc  
The script send the message 123abc on sigfox uplink.

How can I do that with a nodered exec node passing the payload (123abc ) as an argument to the script?  
I would appreciate some help. Being an hobbyist,..... at time is difficult.  
Thank you

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [25 November 2021 09:27 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/2 "2021-11-25T09:27:57Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21451b688584893aa635b70311fcc04f583dd0dd.png)

Should work - make sure you add a space at the end of the command line after .py

And you tick the Append msg.payload

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [25 November 2021 10:53 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/3 "2021-11-25T10:53:00Z")

</div>

Thank you. Perfect

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 November 2021 11:00 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/4 "2021-11-25T11:00:10Z")

</div>

in general for python I would add the -u flag as well to ensure any output is unbuffered and sent back immediately... eg `python2 -u /path...`

---

<div class="post-metadata">

**Author:** ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)\
**Post date:** [26 November 2021 06:46 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/5 "2021-11-26T06:46:51Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 December 2021 08:50 UTC](https://discourse.nodered.org/t/execute-python2-script-with-payload/54255/7 "2021-12-10T08:50:15Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
