CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    609

    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.
    http://www.uovalor.com :: Free UO Server

  2. #2
    Join Date
    Nov 2008
    Location
    Netherlands
    Posts
    77

    Re: Getting screen return from system()?

    why not do it directly without commands

  3. #3
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664

    Re: Getting screen return from system()?


  4. #4
    Join Date
    Jul 2007
    Posts
    609

    Re: Getting screen return from system()?

    Quote Originally Posted by cj-wijtmans View Post
    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.
    http://www.uovalor.com :: Free UO Server

  5. #5
    Join Date
    Jul 2007
    Posts
    609

    Re: Getting screen return from system()?

    Quote Originally Posted by j0nas View Post
    I'll check that out. I'm guessing the FILE is a file stream I can read that represents the output? Is this correct?
    http://www.uovalor.com :: Free UO Server

  6. #6
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Re: Getting screen return from system()?

    Quote Originally Posted by Red Squirrel View Post
    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().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured