basic.%popen
Creates pipe between calling process and command.
Syntax
pointer=(char*)%popen(command, type )
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.
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.
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
