# how to kill a python script running in gateway?

**URL:** <https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640>\
**Category:** Python\
**Created:** [July 22, 2009, 12:24pm UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640 "2009-07-22T12:24:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![john01](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@john01](https://forums.digi.com/u/john01)\
**Post date:** [July 22, 2009, 12:24pm UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/1 "2009-07-22T12:24:09Z")

</div>

I am new Digi python programming , I have following question about python script …

Please help me

1. I have upload a python script with web browser to gateway , and runnning it with telnet command, python \*\*\*.py, But this script file is a while loop that run forever, if I want to kill it for modify , what shoud I do ? Using another telnet  
connect to the gateway with kill command ?

2. is there a vi editor inside the gateway ? , when I using  
telnet , I can not use vi in this box

---

<div class="post-metadata">

**Author:** ![DigiGuy42](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@DigiGuy42](https://forums.digi.com/u/DigiGuy42)\
**Post date:** [July 22, 2009, 2:20pm UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/2 "2009-07-22T14:20:28Z")

</div>

1. There is not a way built into the system to kill scripts that are running. However, for debugging purposes at least, it’s usually not to hard to build into the script itself a way to cause it to exit. What some of the demo apps do is place listen socket on a port, and cause the script to exit if they receive a connection on that port. Certainly not something that you want to leave in a final product, but adequate for testing.

2. There is no editor in the box. You’ll have to edit your scripts on another machine and then upload them.

---

<div class="post-metadata">

**Author:** ![deancs](https://avatars.discourse-cdn.com/v4/letter/d/c0e974/32.png) [@deancs](https://forums.digi.com/u/deancs)\
**Post date:** [July 22, 2009, 11:40pm UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/3 "2009-07-22T23:40:15Z")

</div>

On the X4 under Management/Connections each excuting python script shows up as an active system connection. The UI provides a mechanism to select one and delete it however I have not had any success with this.

Either I am not using this correctly or there is a bug in the GW software.

---

<div class="post-metadata">

**Author:** ![john01](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@john01](https://forums.digi.com/u/john01)\
**Post date:** [July 23, 2009, 2:26am UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/4 "2009-07-23T02:26:47Z")

</div>

\>\>What some of the demo apps do is place listen socket on a port, and cause the script to exit

Hi GigiGuy42,  
Could you post some demo code for this ?! Or where I can get it ?!

Thank you

---

<div class="post-metadata">

**Author:** ![cpopp](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cpopp](https://forums.digi.com/u/cpopp)\
**Post date:** [July 23, 2009, 3:45am UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/5 "2009-07-23T03:45:02Z")

</div>

Hi,

[http://www.digi.com/wiki/developer/index.php/TCP\_to\_Zigbee\_Dynamic\_Name\_Mapping#Quit\_socket\_in\_read\_list](http://www.digi.com/wiki/developer/index.php/TCP_to_Zigbee_Dynamic_Name_Mapping#Quit_socket_in_read_list)

[http://www.digi.com/wiki/developer/index.php/Card\_Swipe\_Demo#Main\_loop:\_Quit\_socket\_reading](http://www.digi.com/wiki/developer/index.php/Card_Swipe_Demo#Main_loop:_Quit_socket_reading)

The previous two examples show how you can use a listening socket to terminate an application when it receives a connection at a particular port.

I attached a simple example that demonstrates one way of doing it. The attached script has a loop that does a print out to the console until a socket connection is opened on port 32000.

Chris

---

<div class="post-metadata">

**Author:** ![52637p](https://avatars.discourse-cdn.com/v4/letter/5/c6cbf5/32.png) [@52637p](https://forums.digi.com/u/52637p)\
**Post date:** [July 23, 2009, 12:49pm UTC](https://forums.digi.com/t/how-to-kill-a-python-script-running-in-gateway/2640/6 "2009-07-23T12:49:17Z")

</div>

Python threads are listed for informational purposes. They can not be killed with either the “kill” CLI command or via the connection management in the webUI.
