Computing.Net > Forums > Linux > getting command output

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

getting command output

Reply to Message Icon

Name: thanatos
Date: February 16, 2005 at 08:33:32 Pacific
OS: linux
CPU/Ram: intel pentium 4 256mb
Comment:

Does anyone know how to execute a linux command from a c program and get the output of the command in a string instead of on the console?

Eg,
system("pwd") won't work becuase the output goes to the console. I'd need something like

char *result = system("pwd")

but I don't think that exists. :(

Thanks in advance for any help.



Sponsored Link
Ads by Google

Response Number 1
Name: thanatos
Date: February 16, 2005 at 08:45:09 Pacific
Reply:

Seems my only option might be to redirect to a file and read it back.


0

Response Number 2
Name: thanatos
Date: February 16, 2005 at 08:52:11 Pacific
Reply:

lol..I think I have the answer...a pipe.

sorry, I'm a bit new to linux. :D


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: getting command output

redirecting the /dev/modem output?? www.computing.net/answers/linux/redirecting-the-devmodem-output/21587.html

the command netstat www.computing.net/answers/linux/the-command-netstat/26900.html

How can I get linux command source? www.computing.net/answers/linux/how-can-i-get-linux-command-source/21733.html