Publishing MQTT messages from serial commands

I am using the BG95 modem and MQTT protocol to publish messages to a broker server. I have no problem publishing using the Qcom tool, but I need to publish using only serial commands and no physical pressing of Control+Z. Does anyone know how this can be done?

I have tried to send:

which should be attempting replicate what the Qcom tool is doing, but I just get “ERROR”.

That syntax doesn’t look right to me. Maybe instead: