How do I print a web page from a shell prompt or shell script?
You need to use html2ps command convert HTML to PostScript. . The HTML code can be retrieved from one or more URL:s or local files, specified as parameters on the command line. If no parameter is given, html2ps reads from standard input.
Install html2ps
Type the following command under Debian / Ubuntu Linux to install the package:
# apt-get update && apt-get install html2ps
Turn on EPEL repo under Fedora / RHEL / CentOS Linux and type the following command to install html2ps package:
# yum install html2ps
Get HTML source code
Type the following command:
$ html2ps http://example.com/file.html
$ html2ps http://www.cyberciti.biz/tips/networking-subnet-mask.html
To print a web page, pipe output using lpr or lp command:
$ html2ps http://www.cyberciti.biz/tips/networking-subnet-mask.html | lpr
$ html2ps http://www.cyberciti.biz/tips/networking-subnet-mask.html | lp -d hpdjet
Further readings:
- man page lp, lpr and html2ps
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -

