UR+Robotiq Screwdrivering solution

Hello, I am trying to control the screwdriver rotation in the UR+Robotiq Screwdrivering solution by sending scripts from my computer to the robot. This works on the teach pendant, but the program does not execute the rotation as expected. What could be the reason for this?

import socket

def RobotInterface(command: str):
    # initialize variables
    robotIP = "192.168.1.10"
    PORT = 30002
    # create socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((robotIP, PORT))  # connect to UR port 30001
    s.send(command.encode())  # encode data and send through socket
    s.close()  # close the socket
    print("Script Command Complete")

moves = ['def moves():',
         'set_digital_out(2,True)',
         # 'movel(pose_add(get_actual_tcp_pose(),p[0,0,-0.1,0,0,0]))',
         'rq_screw_activate()',
         'rq_screw_turn(3,1,0,100,False,9)',
         'set_digital_out(2,False)',
         'end']

cmd = ''
for line in moves:
    cmd += line + '\n'

RobotInterface(cmd)

Answer a very similar question the other day.

And your problem looks exactly the same.

By the way I do think you should switch to the primary interface instead of the secondary one
https://www.universal-robots.com/articles/ur/interface-communication/overview-of-client-interfaces/

Kind Regards