Printing files from the command line using 'lpr'

From CUC3
Jump to navigation Jump to search

You cannot print files directly from one of the clusters so the first thing you need to do is transfer the file to your workstation. This can be done using the scp command, more info in the scp tutorial. As a quick example, I want to print the file FES.ps on the printer queue eclipse-col. This will print single sided and in colour on the printer called eclipse. More info about the print queues available can be found here.

So - here we go!

  • copy file to your workstation

This will copy the file to csw34's home directory on the workstation serenity:

scp FES.ps csw34@serenity:~/csw34
  • print the file

Change into a shell on your workstation and head to your home directory or wherever you saved the file, then use the lpr command:

cd ~csw34
lpr -P eclipse-col FES.ps

That should be it! Make sure you specify a printer that you can access! Checking the name of the one in your office is a good start. :)

If this is all too much hassle you can use the rlpr command which is installed on the Wales group clusters and tardis to do very basic printing of Postscript files to the network printers. rlpr is much less reliable than the method above, as it can't retry the job if there's an error such as the printer being unplugged or a network glitch.

WARNING: you cannot print PDFs from the command line like this! Instead, open them on your workstation with Adobe Acrobat Reader and print them from there

You can of course convert pdfs to ps and then print them from the command line. A handy function in your .bashrc will even print 2 pages of pdf per page:

dpr () {
   if [  "$#" -eq 0 -o "$1" == "-h" -o "$1" == "--help" ]
   then
       echo "dpr <file>"
       echo "print a pdf at 50% (2 pages per side)"
   else
       acroread -toPostScript -pairs $1 temp.ps
       a2ps temp.ps
       rm temp.ps
   fi
}

There is more information about this on the conversion between different image file formats page.