# popen function

popen is used to read and write to a unix pipe.

This function is NOT included in 'C Programming Language' (ANSI) but can be found in 'The Standard C Library' book.

    Library:   stdio.h

    Prototype: FILE *popen(const char *command, const char *type);

    Syntax:    FILE *fp;
    	   fp = popen( "ls -l", "r");

    Notes:
    	command - is the command to be issued.
    	type    - r - read O/P from command.
                    - w - Write data as I/P to command.

## Examples:

example program.

## Notes:

- popen will always execute the command from within the Bourne shell.
- popen feeds the STDOUT back to your program. If you want STDERR, the following will do the trick.

      	fp=popen("ls -l 2>&1", "w");
      		        AAAA
      		        ||||

## See Also:

- fgetc Get a character from a file.
- fputc Put a character into a file.man pages
- fprintf Put a formatted line into a file.
- fopen Open a file.
- fclose Close a file.
- pclose Close a pipe.
- system Open a pipe.

Top | Master Index | Keywords | Functions