Pipe pipeline application. A friend of linux must know the pipe (pipeline) function provided by shell. maybe you do not know his full name yet. you have never used the following command: catINSTALL | more commands of this type. a linux user must know the pipe (pipeline) function provided by shell. maybe you do not know its full name, you have never used such a command:
Cat INSTALL | more
This type of command is used by pipeline technology, which is different from redirection.
The popen function is provided in PHP to open a pipeline:
Int popen (string command, string mode );
Popen () open a pipeline, that is, open the processing file pointer. After opening an MPs queue, a file pointer is returned. the subsequent usage is the same as that for reading and writing common files. Let's take a look at the following:
$ Fp = popen ("/bin/ls-l-FN/ect", "r ");
While (! Feof ($ fp ))
Ehco fgets ($ fp, 4096 )."
";
Pclose ($ fp );
?>
Try the output.
Pipeline is widely used. for example, we can open a sendmail pipeline to send emails. Pipelines are easier to understand than sockets. The socket must be used to understand how to interwork with sendmail, while the pipeline action can be used to pre-process common files. Take a look at the following program and you will understand that this program will send an email to The yqqfgq@china.com:
$ Fp = popen ("/usr/sbin/sendmail yqqfgq@china.com", "w ");
$ Message = "Hi! Yes, I am yqqfgq! :) N ";
Fputs ($ fp, "Subject: $ subjectn ");
Fputs ($ fp, "From: yqqfgqn ");
Fputs ($ fp, "Reply-to: yqqfgq@china.com ");
Fputs ($ fp, $ message );
Fputs ($ fp ,".");
Pclose ($ fp );
?>
Easy to use! That's all. If you have any comments, contact me. Yqqfgq@china.com
Pipeline function, maybe you do not know its full name, you have never used this command: cat INSTALL | more this type of command...