SSH SCP Linux Printing

From FMYiRCWiki

Jump to: navigation, search

SSH/SCP Linux Printing -- THIS DOCUMENT IS UNDER CONSTRUCTION --


Contents


Summary

This document describes a method to send reports to remote locations for printing via SSH/SCP. FTP may also be used here instead of SSH/SCP, but this document specifically focuses on SSH/SCP.


Process

  • Set up a printer in FMYiRC which makes use of SSH/SCP.
    • Create an account in FTPSCP which would send files to this location.
      • From Main Menu, go to FTPSCP Accounts Database
      • Add New Account
      • Type in a short descriptive name in Account Name: (i.e., Remote Printer)
      • Set Method to SCP
      • Type in IP address or hostname of computer at remote location which will be accepting these files via SCP
        • This will probably require the WAN (Internet) IP address of that remote computer, not it's local (LAN) IP.
      • Set Port to 22 unless you have a reason to change it
      • Type in User Name and Password
      • Put /home/toprint/usr in Directory if using the sample script
      • Hit Add Account
      • Make a note of the new Account Number
    • Set up a printer like you normally would:
      • From Main Menu, go to Printer Admin
      • Choose Add New Printer
      • Type in Abbr, Descr, & choose Location
      • In Print Command, use php auto_ftpscp ACCT# send
        • WHERE ACCT# is the FTPSCP account number you set up previously.
      • Hit Add Printer
      • Be sure to give anyone who needs to print to this printer access via User Admin!
  • Set up a computer at the remote location
    • Must be setup to accept files via SSH/SCP.
      • This step may involve some extra networking (i.e., firewall/router IP or port forwarding in order to get incoming SSH/SCP connections to this machine)
    • Create a directory for files to be placed in
      • mkdir /home/toprint
      • mkdir /home/toprint/usr
    • Create a script to run by cron every minute which prints all files in /home/toprint/usr with a .ps file extension. For a sample script, please see the Sample Script section of this document.
    • Call the script print_all_ps and place into the /home/toprint directory.
    • Create cron entry:
      • echo "* * * * * root /home/toprint/print_all_ps" >> /etc/crontab
    • Restart Cron
      • /etc/rc.d/init.d/crond restart

Sample Script

The following is a sample printing script in use by an agency which uses FMYiRC to print to a remote printer. This particular printer does not take well to Internet communications. It works fine, however, on the local network. For this example, the LPRng Linux printing system is used. This script allows backups to be made AND keeps a log too for debugging purposes.

#!/bin/sh
# Look for any .ps files.  If there are any, send them to the printer!
printcmd="lpr -Plp_copier"

cd /home/toprint

files=`ls -c1 /home/toprint/usr/*.ps`

for x in $files
do
        $printcmd $x 1>/dev/null 2>/dev/null
        mv $x $x.old

        echo `date`: $x >> /home/toprint/print_all_ps.log
done
Personal tools