# Printing a Tag Value

**URL:** <https://forum.inductiveautomation.com/t/printing-a-tag-value/113244>\
**Category:** Ignition\
**Created:** [January 13, 2026, 1:21pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244 "2026-01-13T13:21:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![asmith](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@asmith](https://forum.inductiveautomation.com/u/asmith)\
**Post date:** [January 13, 2026, 1:21pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/1 "2026-01-13T13:21:40Z")

</div>

If someone could help point me in a direction, it would be much appreciated.

What I am running into is when

```python
print '\02Telegram Type=Job\nJob ID=1\nRecipe Name=Standard Recipe\nProduct Serial Number=0815sub\03'

```

I get the result I’m looking for, which is

Telegram Type=Job  
Job ID=1  
Recipe Name=Standard Recipe  
Product Serial Number=0815sub

When I try this

```python
tag_path = "[default]ASTUData"

results = system.tag.readBlocking([tag_path])

print str(results[0].value)

```

With a result of

'\02Telegram Type=Job\nJob ID=1\nRecipe Name=Standard Recipe\nProduct Serial Number=0815sub\03'

Is there different function I need to be using for the tag information to have the same print result as the plain text?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2026, 1:27pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/2 "2026-01-13T13:27:30Z")

</div>

How are you putting the String value into the tag in the first place?

---

<div class="post-metadata">

**Author:** ![asmith](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@asmith](https://forum.inductiveautomation.com/u/asmith)\
**Post date:** [January 13, 2026, 1:30pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/3 "2026-01-13T13:30:57Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/7907427cc2b53de41952137df7beb6af2c5fb712.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2026, 1:31pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/4 "2026-01-13T13:31:30Z")

</div>

You’ll need to write it from scripting instead. You can’t type control characters into that text box.

---

<div class="post-metadata">

**Author:** ![asmith](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@asmith](https://forum.inductiveautomation.com/u/asmith)\
**Post date:** [January 13, 2026, 1:37pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/5 "2026-01-13T13:37:44Z")

</div>

I am very new to this platform, do you have an example or possibly elaborate. What will eventually happen is the information of this tag will be changing from a data base.

---

<div class="post-metadata">

**Author:** ![asmith](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@asmith](https://forum.inductiveautomation.com/u/asmith)\
**Post date:** [January 13, 2026, 1:47pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/6 "2026-01-13T13:47:12Z")

</div>

So you can get the full picture,

```python
from java.net import Socket
from java.io import PrintWriter, BufferedReader, InputStreamReader, OutputStreamWriter
from java.lang import Exception
import sys

def send_and_receive_multi_line(ip_address, port, message_to_send):
    socket = None
    reader = None
    writer = None
    response_lines = []

    try:
        # 1. Establish connection and set a timeout
        socket = Socket(ip_address, port)
        socket.setSoTimeout(5000) # Timeout in milliseconds (e.g., 5 seconds)

        # 2. Get input and output streams and wrap them with Reader/Writer
        writer = PrintWriter(OutputStreamWriter(socket.getOutputStream(), "UTF-8"), True)
        reader = BufferedReader(InputStreamReader(socket.getInputStream(), "UTF-8"))

        # 3. Send the single-line message with a line terminator
        # The `println` method automatically adds a newline character
        writer.println(message_to_send)
        # Flush the stream to ensure data is sent immediately
        writer.flush()

        # 4. Read the multi-line response
        # The loop will read line by line until `reader.readLine()` returns None,
        # which indicates the end of the stream or the socket is closed by the server.
        # This approach works best if the server closes the connection after sending the full response.
        line = reader.readLine()
        while line is not None:
            response_lines.append(line)
            line = reader.readLine()

    except Exception as e:
        print "Socket Error: %s" % e
        # Handle specific exceptions as needed (e.g., timeout, connection refused)
    finally:
        # 5. Ensure resources are closed
        if writer:
            writer.close()
        if reader:
            reader.close()
        if socket:
            socket.close()

    return "\n".join(response_lines)

# --- Example Usage ---
# Replace with your server's IP and Port
server_ip = "192.168.10.102" 
server_port = 502
# Ensure your message ends with a terminator if the server expects a specific one.
# PrintWriter.println handles standard terminators.
message = "\02Telegram Type=Job\nJob ID=1\nRecipe Name=Standard Recipe\nProduct Serial Number=0815sub\03" 

# Call the function
response = send_and_receive_multi_line(server_ip, server_port, message)

if response:
    print "Received response:"
    print response
else:
    print "No response or an error occurred."

```

This is what I have found that works, where you see

```python
message = "\02Telegram Type=Job\nJob ID=1\nRecipe Name=Standard Recipe\nProduct Serial Number=0815sub\03" 

```

I am needing to replace the static text with a tag which will change every time the script is ran.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 13, 2026, 1:50pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/7 "2026-01-13T13:50:50Z")

</div>

Don't use a tag, use a PrepQuery, since the value will be coming from a database.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2026, 2:00pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/8 "2026-01-13T14:00:52Z")

</div>

Something like this:

```python
tag_path = "[default]ASTUData"
value = '\02Telegram Type=Job\nJob ID=1\nRecipe Name=Standard Recipe\nProduct Serial Number=0815sub\03'

system.tag.writeBlocking([tag_path], [value])

```

---

<div class="post-metadata">

**Author:** ![asmith](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@asmith](https://forum.inductiveautomation.com/u/asmith)\
**Post date:** [January 13, 2026, 8:29pm UTC](https://forum.inductiveautomation.com/t/printing-a-tag-value/113244/9 "2026-01-13T20:29:19Z")

</div>

I have been searching around and this solved my issue

```python
data = "[default]ASTUData"

results = system.tag.readBlocking([data])

raw_val = results[0].value

process = raw_val.replace('\\n', '\n').replace('\\02', '\02').replace('\\03', '\03')

```

Thank you everyone for you help.
