Sponsored Content
Full Discussion: get system() answer ?
Top Forums Programming get system() answer ? Post 10361 by Perderabo on Tuesday 13th of November 2001 10:00:31 AM
Old 11-13-2001
If you want to read the output from the command, you need to use popen rather than system.

The return code from system just tells you whether it could run the command or not.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

urgent answer these please

Hi, Please explain what does '$*' mean. what does the command cd /~abc do, especially what does '~' mean? cheers. (1 Reply)
Discussion started by: uni_ajay_r
1 Replies

2. Programming

can any one answer ????

Q.1 Diffrence between terminal and pseudo-terminal ? Q.2 What is terminal login ? What is a netwok Login ? Q.3 What is meant by baud rate of a terminal ? Q.4 which structure is used for job control in Unix/Linux ?and where these structure are means in which directory ? (2 Replies)
Discussion started by: mobile01
2 Replies

3. Solaris

Can anybody answer this.....

Hi i am trying the threads concept in unix environment using C... but i am getting error of "wait_fd: Couldn't find procinfo for fd 24"... what does this error mean..... help me in solving this issue... Thanks in advance shivamasam (3 Replies)
Discussion started by: shivamasam
3 Replies

4. UNIX for Dummies Questions & Answers

quick answer

i know by posting this people are going to get mad at me but, when i try to download unix for my Windows XP i find a whole bunch of files that i dont know what to do with, so please help, sorry if this has already been posted... or is a stupid question :o (9 Replies)
Discussion started by: DarkestEvil
9 Replies

5. UNIX for Dummies Questions & Answers

Answer them if u can...

Try to answer these questions on Unix: 1.what will be the segment() function do? 2.How Unix is more powerful than Windows? 3.Where ownership details will be stored of a particular file in Unix? 4.State different uses of ^ symbol in regular expressions. 5.What does export command used for?... (5 Replies)
Discussion started by: dreambig
5 Replies

6. Programming

How do I get system answer in c

How do I get the answer of a system call that is printed in the terminal? for example: I execute system("pwd"); and get the answer /home/user/ But because I need to send this result to somewhere, I need to store it in a string. Thanks in advance. (7 Replies)
Discussion started by: eldaran
7 Replies

7. Shell Programming and Scripting

help me to answer this

Hello everyone I update my question. Thanks for your reply joeyg If I type the last command and send to a text file. I get this last >usuarios.txt root pts/0 160.40.35.277 May 22 11:08 still logged in. root pts/0 alopez02 May 22 09:23 - 10:11 (00:47) root pts/0 160.40.35.277 May 20... (0 Replies)
Discussion started by: lo-lp-kl
0 Replies

8. UNIX for Dummies Questions & Answers

I welcome all to answer my Q's

Hi everyone,, I am new to the forum...but not to Unix. I have gathered few questions from my mates who attended interviews in various companies as I have to attend one on dec 3rd for Sys admin position. Please respond with the answers you know and also help with various other interview... (2 Replies)
Discussion started by: impawan
2 Replies

9. Solaris

==please answer the following questions==

Hello :) ! i've few doubts. 1) how can we find the newly attached disk in SOLARIS ? 2) how to change port number of a service ? 3) how can we find that autofs is running in our system without using svcs and prstat commands ? 4) we know that there are several types of dns servers in... (0 Replies)
Discussion started by: vamshigvk475
0 Replies
POPEN(3)						   BSD Library Functions Manual 						  POPEN(3)

NAME
popen, pclose -- process I/O LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> FILE * popen(const char *command, const char *type); int pclose(FILE *stream); DESCRIPTION
The popen() function ``opens'' a process by creating an IPC connection, forking, and invoking the shell. Historically, popen was implemented with a unidirectional pipe; hence many implementations of popen only allow the type argument to specify reading or writing, not both. Since popen is now implemented using sockets, the type may request a bidirectional data flow. The type argument is a pointer to a null-terminated string which must be 'r' for reading, 'w' for writing, or 'r+' for reading and writing. In addition if the character 'e' is present in the type string, the file descriptor used internally is set to be closed on exec(3). The command argument is a pointer to a null-terminated string containing a shell command line. This command is passed to /bin/sh using the -c flag; interpretation, if any, is performed by the shell. The return value from popen() is a normal standard I/O stream in all respects save that it must be closed with pclose() rather than fclose(). Writing to such a stream writes to the standard input of the command; the command's standard output is the same as that of the process that called popen(), unless this is altered by the command itself. Conversely, reading from a ``popened'' stream reads the command's standard output, and the command's standard input is the same as that of the process that called popen(). Note that output popen() streams are fully buffered by default. The pclose() function waits for the associated process to terminate and returns the exit status of the command as returned by wait4(). RETURN VALUES
The popen() function returns NULL if the fork(2), pipe(2), or socketpair(2) calls fail, or if it cannot allocate memory. The pclose() function returns -1 if stream is not associated with a ``popened'' command, if stream has already been ``pclosed'', or if wait4(2) returns an error. ERRORS
The popen() function does not reliably set errno. SEE ALSO
sh(1), fork(2), pipe(2), socketpair(2), wait4(2), fclose(3), fflush(3), fopen(3), shquote(3), stdio(3), system(3) STANDARDS
The popen() and pclose() functions conform to IEEE Std 1003.2-1992 (``POSIX.2''). HISTORY
A popen() and a pclose() function appeared in Version 7 AT&T UNIX. BUGS
Since the standard input of a command opened for reading shares its seek offset with the process that called popen(), if the original process has done a buffered read, the command's input position may not be as expected. Similarly, the output from a command opened for writing may become intermingled with that of the original process. The latter can be avoided by calling fflush(3) before popen(). Failure to execute the shell is indistinguishable from the shell's failure to execute command, or an immediate exit of the command. The only hint is an exit status of 127. The popen() argument always calls sh(1), never calls csh(1). BSD
June 24, 2011 BSD
All times are GMT -4. The time now is 09:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy