The script:
#!/bin/bash
interface=enp4s0
mac_address=$(ip link show $interface | grep ether | awk '{print $2}')
cat > /dev/usb/lp0 <<EOF
SIZE 30 mm,90 mm,CLS,TEXT 200,40,0,90,2,2,"MAC Address of $interface:",TEXT 140,40,0,90,2,2,"$mac_address",PRINT 1,END
>EOF
I am using TSPL language to print to the character device. The problem is that content to be printed has to be in double quotes. So for example TEXT 200,40,0,90,2,2,"Some text to be printed". I also want to embed a variable inside the text.
echo "SIZE 30 mm,90 mm,CLS,TEXT 200,40,0,90,2,2,"MAC Address of $interface:",TEXT 140,40,0,90,2,2,"$mac_address",PRINT 1,END > /dev/usb/lp0 is not working because the double quote nesting is breaking the commands of TSPL.
The error I am getting with heredoc is
warning:here-document at line 8 delimited by end-of-file (wanted `EOF')
>EOFand not justEOFto close the heredoc?