Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux print file and send mail     - Use pg_basebackup build PostgreSQL streaming replication environment (Database)

- Docker in the development and practice of IFTTT (Server)

- Linux network security backdoor technology and advanced skill practice (Linux)

- Setup Qt development environment under Linux (Linux)

- Learning Linux coding style (Programming)

- To compile and install OpenCV-2.3.1 FFmpeg-2.1.2 under CentOS (Linux)

- Spring + Log4j + ActiveMQ remote logging - Analysis of combat (Server)

- Linux System Getting Started Tutorial: how to find information on Linux-embedded module (Linux)

- Redis logging system (Database)

- Commonly used Linux system camouflage method (Linux)

- Linux based serial programming (Programming)

- To install the Contiki development toolchain on Ubuntu (Linux)

- Dom4j change XML coding (Programming)

- MyCAT read and write separation of MySQL (Database)

- Quagga use authentication on strengthening BGP session security (Linux)

- Grading defense against Linux server attacks (Linux)

- Git Getting Started tutorial (Linux)

- Binding unofficial Google Drive and Ubuntu 14.04 LTS (Linux)

- The principle Httpclient4.4 (execution request) (Programming)

- Spark parquet merge metadata problem (Server)

 
         
  Linux print file and send mail
     
  Add Date : 2017-01-08      
         
         
         
  By the previous description, I believe your commands and features of Linux have a basic understanding of this section explains how to print files and send messages.
File Print

If you want to print a text file, it is best to handle it in advance, including the adjustment of margins, set the row height, set the title, etc., so print out documents more attractive and easy to read. Of course, the process also can not print, but may be more ugly.

Most Linux comes with two powerful nroff and troff text formatting tools, but relatively old, very few people use, interested readers can learn on their own, no in-depth explanation of this tutorial.
pr command

pr command to convert the text file into a format suitable for printing, it can split large files into multiple pages to print, and add a title for each page.

pr command syntax is as follows:
pr option (s) filename (s)
pr command simply changing the file display style on the screen and print output style, and does not change the file itself. The following table several options pr command:
Option Description
-k print into several columns, the default is 1.
-d double spaced (not all versions of pr are valid).
-h "header" to set the title of each page.
-t Do not print the title and the top and bottom margins.
-l PAGE_LENGTH how many lines per page. The default is a total of 66 lines per page, text, accounting for 56 rows.
-o MARGIN number of spaces to indent each row.
-w PAGE_WIDTH multi-column output, set the page width, the default is 72 characters.
For example, food that contains a lot of file names food, using pr command is divided into two print, and set the page titled "Restaurants".

First, view the file contents:
$ Cat food
Sweet Tooth
Bangkok Wok
Mandalay
Afghani Cuisine
Isle of Java
Big Apple Deli
Sushi and Sashimi
Tio Pepe's Peppers
........
$
Then use the Print command pr:
$ Pr -2 -h "Restaurants" food
Nov 7 9:58 1997 Restaurants Page 1

Sweet Tooth Isle of Java
Bangkok Wok Big Apple Deli
Mandalay Sushi and Sashimi
Afghani Cuisine Tio Pepe's Peppers
........
$
lp and lpr command

lp and lpr command to transfer the file to the printer for printing. Pr command using the file format, ready to use these two commands to print.

Printers are generally set by the system administrator, the following example uses the default printer to print food item:
$ Lp food
request id is laserp-525 (1 file)
$
Successful execution of the command will return a representation of the print job ID, the ID can be canceled by print or view the print status.

If you want to print multiple copies of a file, you can use the lp -nNum option or options -Num lpr command. Num is a number that can be freely set.

If the system is connected to more than one printer, you can use the lp command -dprinter option, or the option -Pprinter lpr command to select a printer. printer printer name.
lpstat and lpq command

lpstat command to see printer queue buffer (the number of documents waiting to be printed), including the task ID, owner, file size, request time and the status of requests.

Tip: Wait to print files will be placed in the printer's buffer queue.

For example, use lpstat -o command to view all the printer files waiting to print, including your own:
$ Lpstat -o
laserp-573 john 128865 Nov 7 11:27 on laserp
laserp-574 grace 82744 Nov 7 11:28
laserp-575 john 23347 Nov 7 11:35
$
lpstat -o command output queue file in accordance with the print order.

Information with lpstat -o lpq command displays slightly different:
$ Lpq
laserp is ready and printing
Rank Owner Job Files Total Size
active john 573 report.ps 128865 bytes
1st grace 574 ch03.ps ch04.ps 82744 bytes
2nd john 575 standard input 23347 bytes
$
The first line printer status. If the printer is out of paper or is not available, additional information will be output.
cancel and lprm command

lprm and cancel print requests are used to terminate the lp and lpr. Using these two commands, you need to specify the ID (returned by lp or lpq) or the name of the printer.

For example, cancel a print request by ID:
$ Cancel laserp-575
request "laserp-575" cancelled
$
If you want to cancel the file is printing, you can not specify the ID, you can simply specify the name of the printer:
$ Cancel laserp
request "laserp-573" cancelled
$

lprm command to remove the current user is waiting to print the file, use the job number as an argument to cancel the specified file, use the dash (-) as an argument to cancel all files.

For example, to cancel the print job number 575:
$ Lprm 575
dfA575diamond dequeued
cfA575diamond dequeued
$
lprm will return the file name to be canceled.
send email

You can use the mail command to send and receive mail, the following syntax:
$ Mail [-s subject] [-c cc-addr] [-b bcc-addr] to-addr
The meaning of each option are as follows:

Option Description -s message headers. -c To send user, multiple users with a comma (,) separated. -b need to send confidential (BCC) users, multiple users with a comma (,) separated.

For example, send a message to admin@yahoo.com:
$ Mail -s "Test Message" admin@yahoo.com
Hello everyone,
this is Linux tutorial and url is http://see.xidian.edu.cn/cpp/linux/.
Cc:
The first line is the command input, -s indicate the subject of the message behind the admin@yahoo.com is the recipient of the message, enter the command line after the carriage return, will enter the body of the message write, you can enter any text , such as the above two lines. Enter the complete body of the message, you need to press CTRL + D input end, then you will be prompted to enter the Cc address, e-mail CC address, there is no direct Enter to complete the message sent.

You can also redirection operator $ Mail -s "Report 05/06/07" admin@yahoo.com Through the above command, you can put the contents of the file demol.txt as the content of the message to the admin@yahoo.com.

Receive messages without any parameters:
$ Mail
no email
     
         
         
         
  More:      
 
- To configure linux transparent firewall (Linux)
- Linux Command Line Art (Linux)
- Build Eclipse + Maven + Scala-IDEA the Scala Web development environment (Server)
- C ++ function object (Programming)
- OpenResty load balancing MySQL (Database)
- Enterprise Hadoop cluster architecture - DNS installation (Server)
- RedHat / CentOS ext4 partition can not be formatted large supplementary ext4 formatting (Linux)
- Java heap (Heap) and stack difference (Programming)
- RabbitMQ tutorial examples: the Hello RabbitMQ World Java realization (Linux)
- Ubuntu / Fedora / CentOS system how to install Plex Media Server 0.9.9 (Linux)
- Installation through the network Debian 7 (Wheezy) (Linux)
- Java Foundation - implicit conversion vs cast (Programming)
- The PostgreSQL database pg_dump command line does not enter a password method (Database)
- Windows Server 2012 R2 Datacenter install SQL Server 2016 CTP (Database)
- Ubuntu download install and configure Plank Dock (Linux)
- Setting Linux desktop environment, achieve HiDPI display support (Linux)
- How to test your MongoDB application upgrade? (Database)
- Ubuntu under shadowsocks configuration instructions (Linux)
- Customize the output format in Linux history (Linux)
- ASP.NET 5 is connected with the Redis server on the Linux platform (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.