psystem(3) - example usage
Stephen J. Muir
stephen at dcl-cs.UUCP
Tue Jun 25 18:59:43 AEST 1985
I was asked for a program to demonstrate the use of the (recently posted)
"psystem(3)". Here it is.
----------------------------------- cut here ----------------------------------
/* This is NOT an example of a well written program */
main ()
{ int input, output;
static char buf [512];
/* you should really check the return value */
psystem ("dd conv=ucase", &input, &output, 0, 0);
/* pump input into the command */
write (input, "this is my input\n", 17);
/* indicate end-of-file to command */
close (input);
/* collect output - you should really use the return value */
read (output, buf, 512);
/* tidy up */
close (output);
/* collect our zombie */
wait (0);
printf ("The output was \"%s\".\n", buf);
exit (0);
}
--
UUCP: ...!seismo!mcvax!ukc!icdoc!dcl-cs!stephen
DARPA: stephen%lancs.comp at ucl-cs | Post: University of Lancaster,
JANET: stephen at uk.ac.lancs.comp | Department of Computing,
Phone: +44 524 65201 Ext. 4599 | Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution | LA1 4YR
More information about the Comp.sources.unix
mailing list