Results 1 to 5 of 5

Thread: Redirect standard output of external tools

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Redirect standard output of external tools

    How are you calling those external tools? You can use QProcess to call them and intercept their output. Then you can do with it whatever you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jul 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Redirect standard output of external tools

    Hi, thanks for your reply.
    As far as I understood QProcess, I can use it for external tolls that are called as external executable.
    I have a library written in Fortran with a C++ interface that I included in my code and use its function in my code... this functions produce outputs that are not redirected to the GUI. Any idea how can I solve the problem? Maybe the problem is it is Fortran code and doesn't have std::cout?

    Thanks for your help,
    Annalisa

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Redirect standard output of external tools

    It surely doesn't have std::cout Maybe there is some native API that will help you intercept STDOUT from those libraries but the chances are slim. On a POSIX system you could probably use dup2() and pipe2() to create a pipe from stdout that you could read but I am just guessing.

    An alternative is to replace the symbol used by the library to print output to stdout with a custom function that will redirect it elsewhere but this requires knowledge of how the fortran engine works.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2008
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Redirect standard output of external tools

    thank you very much for your time and your help.
    I'll investigate more in the direction you suggest!

    Regards
    Annalisa

Similar Threads

  1. Replies: 2
    Last Post: 29th November 2009, 17:22
  2. Replies: 2
    Last Post: 2nd June 2008, 08:45
  3. Replies: 52
    Last Post: 10th December 2006, 14:32
  4. redirection of standard input and output
    By guestgulkan in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2006, 20:30
  5. Replies: 4
    Last Post: 10th May 2006, 22:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.