Using Ruby to send a series of data strings to a Zebra printer using its IP address.
Here's the Ruby code I've started with:
require 'socket'
streamSock = TCPSocket.new( "127.0.0.1", 20000 )
#streamSock.send( "Hello\n" )
str = streamSock.recv( 100 )
print str
streamSock.close
I need to replace the "Hello\n" piece with ZPL (Zebra Print Language) code of this series of strings:
"^XA" +
"^FO50,50" +
"^A0N50,50" +
"^FDHello, World!^FS" +
"^XZ";
I've tried several ways of using #streamSock.send( "xxx" ) for each line - example: #streamSock.send( "^XA" ) - and then all the other string elements separately.
I tried a few variants of putting the entire string of ZPL codes into a single line, like
streamSock.send( "^XA^FO50,50^A0N50,50^FDHello, World!^FS^XZ" )
The Zebra label printer does not respond. If I send the earlier series of strings to the printer as a text file using another utility, it prints fine.
Any ideas of what the Ruby code should be to make this work?