Printing without using FreeBSD printing subsystems.

At the risk of going off-topic, here's how I print from FreeBSD without using the printing subsystems.

Essential ingredients: Samba installed and sharing a folder[1] with the sticky bit removed[2]. A printer attached to a Linux[3] system attached to the network.

Create this shell script:

Code:
# autoprint.sh
# automatically prints files with the name
# autoprint.pdf in /tmp on 192.168.0.5
# then deletes the file


# mount /tmp on 192.168.0.5
gio mount --anonymous smb://192.168.0.5/tmp
# files are mounted here -> /run/user/1000/gvfs/smb-share:server=192.168.0.5,share=tmp/


# wait for mount to take place
sleep 5


# check mount for autoprint.pdf, if found print and delete
while :
do
lp -dHL-L2300D /run/user/1000/gvfs/smb-share:server=192.168.0.5,share=tmp/autoprint.pdf && echo printing autoprint.pdf && rm /run/user/1000/gvfs/smb-share:server=192.168.0.5,share=tmp/autoprint.pdf
sleep 5
done

Run the shell script from
cron
or a desktop shortcut/launcher. Print files to a pdf file, save into /tmp with the default name, then rename to autoprint.pdf.



[1] I use /tmp as seen in the shell script. This is what my smb4.conf looks like:
Code:
# /usr/local/etc/smb4.conf 12 sept 2022  #


[global]
        server string = Samba Server
        guest account = sambobulous
        create mask = 0777
        inherit permissions = yes
[tmp]
        path = /tmp
        writeable  = yes
        guest ok = yes
        browseable = yes
        create mask = 0777

[2] man chmod(1) - see the 't' option
[3] I use Linux Mint Xfce. The printer is a Brother HL-L2300D.
 
Back
Top