|
-
January 8th, 2009, 11:03 PM
#1
Getting screen return from system()?
when using system() is there a way I can capture the result of it? (ex: the actual error/output on the screen)
Or is there a better way to execute shell commands? In most cases if I can I use built in functions to accomplish the task that I'm using system() for, but in some cases I have to use system(). My program is to administer a Linux server so it does stuff like create/edit/delete users, etc.
One way I'm thinking is I can pipe it to a temp file then read the file, but that's kinda messy, I'm wondering if there's a better way.
-
January 9th, 2009, 09:12 AM
#2
Re: Getting screen return from system()?
why not do it directly without commands
-
January 9th, 2009, 09:42 AM
#3
Re: Getting screen return from system()?
-
January 9th, 2009, 04:52 PM
#4
Re: Getting screen return from system()?
 Originally Posted by cj-wijtmans
why not do it directly without commands
Not everything is possible to do directly in C++ (that I know of), such as creating/editing shell users, restarting services, running a command like rsync, etc.
-
January 9th, 2009, 04:54 PM
#5
Re: Getting screen return from system()?
 Originally Posted by j0nas
I'll check that out. I'm guessing the FILE is a file stream I can read that represents the output? Is this correct?
-
January 10th, 2009, 05:01 AM
#6
Re: Getting screen return from system()?
 Originally Posted by Red Squirrel
I'll check that out. I'm guessing the FILE is a file stream I can read that represents the output? Is this correct?
Yes, I think so. Take a look at the opengroup documentation here and the sample example that reads the output from the 'ls' command - opengroup - popen().
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|