basic.%popen C Function/BASIC Program

basic.%popen

Command basic.%popen C Function/BASIC Program
Applicable release versions: AP/Unix
Category BASIC Program (486)
Description creates a pipe between the calling process and the command to be executed.

"command" Shell command line.

"type" I/O mode, either "r" for reading or "w" for writing.

"pointer" Stream pointer which directs a write to the standard input of the command if the I/O mode is "w", and reads from the standard output of the command if the type is "r".

A stream opened by "%popen()" must be closed by "pclose()". The stream is closed automatically at Pick/BASIC program termination.
Syntax pointer=(char*)%popen(command, type )
Options
Example
char buffer[128]
ptr=(char*)%popen("ls -l","r")
if ptr=0 then crt 'error'; stop
loop
  n=(char*)%fgets(buffer,128,(char*)ptr)
while n#0 do
  print field(buffer,char(0),1)
repeat
%pclose((char*)ptr)
This example executes a C command, capturing the result.
Purpose
Related basic.cfunc
basic.%pclose
basic.%fgets
basic.%fputs
basic.execute.unix
basic.cfunction