newbie - system() or exec()

newbie - system() or exec()

Post by Michal Kolesa » Tue, 06 Feb 2001 22:37:33



Hi,

Is possible save std output of $subject functions to a variable in C?

I would like run standard shell command from C program (trough
system() function in example) and  I would like use the output of that
command
for next manipulate in the C program.

ex:

char *output;
output = system("ls -lap");

--

S pozdravem,
Michal Kolesar

http://www.egarden.cz
server of free unix services

 
 
 

newbie - system() or exec()

Post by Arthur H. Gol » Wed, 07 Feb 2001 11:23:34



> Hi,

> Is possible save std output of $subject functions to a variable in C?

> I would like run standard shell command from C program (trough
> system() function in example) and  I would like use the output of that
> command
> for next manipulate in the C program.

> ex:

> char *output;
> output = system("ls -lap");

> --

This seems to be a perfect situation for popen (see `man
popen' for details).
In short, popen allows you to run a process and read its
results just like a filestream.

HTH,
--ag

--
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)

--
A: Yes I would. But not enough to put it out.

 
 
 

1. What's the difference between in Exec and Exec exec ...

Well, I mean, in fvwm the normal way to add an item in fvwm's Menu
is write Exec exec program_name.
However, Exec program_name will also work.
But, what's the difference between these two ways?
Now, I want to add an item to execute a
command `LC_ALL=en_US.ISO8859-1 xterm'. The first can't work at all.
So I have to write `Exec LC_ALL=en_US.ISO8859-1 xterm'.
Can this make some damages to my system?

Thanks.

--
  Hongzheng Wang
  Department of Electronics Engineering
  Tsinghua University

2. CHROOT

3. Problem with exec of xterm -exec Telnet

4. Aureal Vortex

5. exec $program || exec $alternative

6. xfig - can't export anything but XBM files

7. find -exec find -exec rm

8. PS question

9. Need 'exec.h' file or 'struct exec' definition

10. how is exec CGI different from exec cmd ?

11. Apache and "exec cgi", "exec cmd".

12. SSI newbie: '#exec' can't take arguments?

13. SSI - exec cgi (Apache) - newbie