Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [Moved] system() not running as expected
Forum Updated to NodeBB v4.3 + New Features

[Moved] system() not running as expected

Scheduled Pinned Locked Moved C++ Gurus
5 Posts 4 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rishabhc
    wrote on last edited by
    #1

    Hello,

    I am using the system() function to run a system command. While using the system(), the command I am using is:

    @system("C:\splint-3.1.2\bin\splint first.c>output.txt");@

    However, the output of this is not being correctly sent to the txt file. To be more specific, the txt file is created, however the output is not appended to the file.

    On running the same command from the CMD, the output is correctly sent to the txt file.

    Any idea on what's going wrong?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Moved to C++ Gurus forum as it's completely unrelated to Qt (system is a standard C library function).

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #3

        Try launching your command line app as arguments passed to cmd.exe. I seem to remember having to do this in the past (a long time ago).

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          In general calling system is a bad practice. In your case the problem is related to the command that you are executing not to the source code.

          To solve your issue you might have to log both STDOUT and STDERR to the file. For more info check: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true

          Best regards,
          Leon

          http://anavi.org/

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            "QProcess":http://doc.qt.nokia.com/4.7/qprocess.html should be a good alternative. You have control over stdin and stdout there.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved