Navigation

Operators and Keywords

Function List:

C++ API

: fid = popen (command, mode)

Start a process and create a pipe.

The name of the command to run is given by command. The argument mode may be

"r"

The pipe will be connected to the standard output of the process, and open for reading.

"w"

The pipe will be connected to the standard input of the process, and open for writing.

The file identifier corresponding to the input or output stream of the process is returned in fid.

For example:

fid = popen ("ls -ltr / |tail -3", "r");
while (ischar (s = fgets (fid)))
 fputs (stdout, s);
endwhile

  -| drwxr-xr-x  33 root  root  3072 Feb 15 13:28 etc
  -| drwxr-xr-x   3 root  root  1024 Feb 15 13:28 lib
  -| drwxrwxrwt  15 root  root  2048 Feb 17 14:53 tmp

See also: popen2.

Package: octave