13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 10 ■ THINGS GO IN, THINGS GO OUTOnce you’ve set all of this stuff, you can create a script with two lines per printer (lpadmin to add theprinter and then lpoptions to set its default options), and run it on every newly installed machine. Thefinal line should be as follows to make sure that CUPS picks up the new printers:/etc/init.d/cups restartFinally, you can set the default printer. Either do this manually:lpoptions -d printernameor give your script a command-line input, which takes the following as the default:01 #!/bin/bash02 if [ $# != 1 ]; then03 echo "Script to install all printers and set default printer."04 echo "Usage: $0 defaultprinter"05 exit 1;06 fi07 defaultprinter=$10809 lpadmin -p print1 -L "Room 43" -D "HP LaserJet 4350" -P /usr/share/cups/model/hpijs/HP/HP-LaserJet_4350-hpijs.ppd.gz -v lpd://print1.example.com/print1 -E10 lpadmin -p print2 -L "Room 243" -D "HP LaserJet 4350" -P /usr/share/cups/model/hpijs/HP/HP-LaserJet_4350-hpijs.ppd.gz -v lpd://print2.example.com/print2 -E11 lpoptions -p print1 -o Duplex=DuplexNoTumble -o PageSize=A4 -o InputSlot=Auto InstalledMemory=Mem412 lpoptions -p print2 -o Duplex=DuplexNoTumble -o PageSize=A4 -o InputSlot=Auto InstalledMemory=Mem413 lpoptions -d $defaultprinter14 /etc/init.d/cupsys restart■ Note To override the option settings for a single job, you can set options temporarily on the command line. Forexample, to print in simplex, for the printer we looked at earlier, use this:lpr -P print1 -o TR-Duplex=False myfile.ps10-4. Printing Text Files ReadablyOccasionally you need to print a text file: notes to yourself, notes for someone else, or diff output thatyou want to be able to write on rather than having to use a screen. lp file.txt will straightforwardlydump the text to the printer, but that’s often not very readable. Also, it usually wastes a lot of page space,and it may try to print outside the printable area of the page (meaning that parts are cut off).207Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!