popen(3) Library Functions Manual popen(3)Name
popen, pclose - initiate I/O to/from a process
Syntax
#include <stdio.h>
FILE *popen(command, type)
char *command, *type;
pclose(stream)
FILE *stream;
Description
The arguments to are pointers to null-terminated strings containing respectively a shell command line and an I/O mode, either "r" for read-
ing or "w" for writing. It creates a pipe between the calling process and the command to be executed. The value returned is a stream
pointer that can be used (as appropriate) to write to the standard input of the command or read from its standard output.
A stream opened by should be closed by which waits for the associated process to terminate and returns the exit status of the command.
Because open files are shared, a type "r" command may be used as an input filter, and a type "w" as an output filter.
Diagnostics
The routine returns a null pointer if files or processes cannot be created, or the shell cannot be accessed.
The routine returns -1 if stream is not associated with a `popened' command.
Restrictions
Buffered reading before opening an input filter may leave the standard input of that filter mispositioned. Similar problems with an output
filter may be forestalled by careful buffer flushing, for instance, with For further information, see
The routine always calls and never calls
See Alsosh(1), pipe(2), wait(2), system(3), fclose(3s), fopen(3s)popen(3)
Check Out this Related Man Page
popen(3) Library Functions Manual popen(3)Name
popen, pclose - initiate I/O to/from a process
Syntax
#include <stdio.h>
FILE *popen(command, type)
char *command, *type;
pclose(stream)
FILE *stream;
Description
The arguments to are pointers to null-terminated strings containing respectively a shell command line and an I/O mode, either "r" for read-
ing or "w" for writing. It creates a pipe between the calling process and the command to be executed. The value returned is a stream
pointer that can be used (as appropriate) to write to the standard input of the command or read from its standard output.
A stream opened by should be closed by which waits for the associated process to terminate and returns the exit status of the command.
Because open files are shared, a type "r" command may be used as an input filter, and a type "w" as an output filter.
Diagnostics
The routine returns a null pointer if files or processes cannot be created, or the shell cannot be accessed.
The routine returns -1 if stream is not associated with a `popened' command.
Restrictions
Buffered reading before opening an input filter may leave the standard input of that filter mispositioned. Similar problems with an output
filter may be forestalled by careful buffer flushing, for instance, with For further information, see
The routine always calls and never calls
See Alsosh(1), pipe(2), wait(2), system(3), fclose(3s), fopen(3s)popen(3)
Hi,
I am working on a custom made FTP application. The application is behaving erratically for the "ls" command. Wild card character passed to the "ls" command (like "ls *temp") is giving inconsistent results. On debuggin I have found that the "ls" command is implemented as shown below in the... (7 Replies)
Hi there,
I'm facing a problem running the tar command with the popen function.
FILE* fp = popen("tar czf - textfile","r")
// output
this program should give the output to the stdout. I don't know if it is possible and which function like fprint() etc. should I use.
I suppose that I... (4 Replies)
hi,
how to work with a background process without a controlling terminal to make use of popen or system call ?
when ever i use popen or system function call in foreground process, there is no problem with respect to that .. but when the same program is run as a background process without a... (7 Replies)
hello,
how can I filter and get the latest order number (last five digits) below:
input file:
johnmm00001
maryyy00121
johnm100222
johnmm00003
maryyy00122
output file:
johnmm00003
maryyy00122
johnm100222 (6 Replies)
Hi,
I am trying to filter out those paragraphs that contains 'CONNECT', 'alter system switch logfile'. That means say the input file is :
-------------------------------------------------------
Wed Jun 7 00:32:31 2006
ACTION : 'CONNECT'
CLIENT USER: prdadm
CLIENT TERMINAL:
Wed Jun 7... (7 Replies)
Hi all...
I have the following code:
FILE *fp = popen(" gzip -dc /somemount/somefile.gz", "r");
while(fgets(buffer, 1024, fp))
{
some code....
}
"/somemount" is a mount of some network drive. Sometimes error occurs in while loop - I can see the following "Input/Output error"... (4 Replies)
Hi @all,
i really stuck in programming a tool with bidirectional process communication (popen(cmd, "rw") ... something like that ;-)).
Here is the code:
if(pipe(p_stdin) != 0 || pipe(p_stdout) != 0) {
fprintf(stderr, "Aufruf von pipe() schlug fehl.\n");
exit(1);
}
... (6 Replies)
Hi everyone,
Is there any way to use the pipe "|" operator to pass more than one input? For instance do:
(command1) (command2) | command3
with command 3 taking 2 parameters?
or maybe using ``s?
Thanks!
Anthony (4 Replies)
Hi all,
Can you please let me know how to achieve the below thing
AAABBCC@#$W123
123@#$DFG<>.
Output:
AAABBCW123
123DFG
i.e I want to filer only alphanumerics from the strings (4 Replies)
So, I am new to shell scripting and have a few problems.
I know how to read from standard input but I do not know how to really compare it to say, a character. I am trying to compare it to a character and anything exceeding just a character, the user will get an output message, but the program... (7 Replies)
Hi
I want to filter my files which has more than 1 underscores in it.how can i achieve this.
Ex: if my file name is a_b_c, a_b.
my command should result only a_b_c
Thanks
Pracheth (10 Replies)
Hi,
I have two files A and B and would like to use A as a filter. Like this:
File A.txt: Contains a list of IP addresses, each one occurring only once and in order:
10.0.0.1
10.0.0.2
10.0.0.4
10.0.0.8
File B.txt: Contains the same IP addresses with a corresponding ping time each (in... (16 Replies)