# Barcode Printer Issues

**URL:** <https://forum.inductiveautomation.com/t/barcode-printer-issues/11952>\
**Category:** General Discussion\
**Created:** [July 20, 2016, 6:12pm UTC](https://forum.inductiveautomation.com/t/barcode-printer-issues/11952 "2016-07-20T18:12:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [July 20, 2016, 6:12pm UTC](https://forum.inductiveautomation.com/t/barcode-printer-issues/11952/1 "2016-07-20T18:12:52Z")

</div>

I am attempting to send a string to a barcode printer. I found two scripts, at the end of this post, on the forum.

The first successfully prints the barcode the first time it is run, but does nothing the second time it runs. Restarting the printer allows printing one more barcode.

The second script does not do anything; no errors, no printer output.

If anyone can tell me how to get script 1 to print labels each time it runs, or how to get script 2 to work at all, or has a better solution, I would be very grateful!!!

Script 1---------------------------------------

strMessage="""  
P  
E2;F2  
H0;o5,5;d3,PART NUMBER FORMAT  
B1;o10,10;i1;d0,13  
R  
E2  
F1_123_  
“”"

#================

# Import Socket Library

#================  
import socket

#================

# Get Printer IP and Port

#================  
strIP = ‘192.168.123.87’  
port=9100

#================

# Send Data to Printer

#================  
updSocket=socket.socket(socket.AF\_INET,socket.SOCK\_STREAM)  
updSocket.connect((strIP,port))  
updSocket.sendall(strMessage)  
updSocket.close

Script 2---------------------------------------

strMessage="""  
P  
E2;F2  
H0;o5,5;d3,PART NUMBER FORMAT  
B1;o10,10;i1;d0,13  
R  
E2  
F1_123_  
“”"

#================

# Import Socket Library

#================  
import socket

#================

# Get Printer IP and Port

#================  
strIP = ‘192.168.123.87’  
port=9100

#================

# Send Data to Printer

#================   
import system  
udpSocket=socket.socket(socket.AF\_INET,socket.SOCK\_DGRAM)  
udpSocket.sendto(strMessage,(strIP,port))

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [July 20, 2016, 6:31pm UTC](https://forum.inductiveautomation.com/t/barcode-printer-issues/11952/2 "2016-07-20T18:31:52Z")

</div>

In script 1, I added “()” to the socket.close so that it is socket.close() now and all is well…
