From ed6ba0c87d0956f4fc402f8a73369e2ea5930c2e Mon Sep 17 00:00:00 2001 From: Henrik Wallin <hedda@lysator.liu.se> Date: Mon, 29 Nov 1999 04:52:02 +0100 Subject: [PATCH] Simple example-section added in File I/O-chapter. Rev: tutorial/tutorial.wmml:1.165 --- tutorial/tutorial.wmml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tutorial/tutorial.wmml b/tutorial/tutorial.wmml index 8a252cc100..cee62ee678 100644 --- a/tutorial/tutorial.wmml +++ b/tutorial/tutorial.wmml @@ -4984,6 +4984,29 @@ Append the string <i>str</i> onto the file <i>file</i>. Returns number of bytes </section> +<section title="Simple example"> + +Here is a simple example of how to use the Stdio-functions. +<p> +<example language=pike> +string grep(string indata, string needle) +{ + object out=Stdio.File(),in=Stdio.File(); + object process= + Process.create_process(({"/bin/grep",needle}), + (["stdin":out->pipe(), + "stdout":in->pipe()]) ); + out->write(indata); + out->close(); + process->wait(); + return in->read(); +} +</example> +This function filters the indata through the UNIX-command /bin/grep +and return the result. + +</section> + <section title="A more complex example - a simple WWW server"> As most of you know, WWW WWW (World Wide Web), works by using a -- GitLab