Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Redirect QProcess::execute() output to /dev/null

Redirect QProcess::execute() output to /dev/null

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    Madesh R
    wrote on last edited by
    #1

    Hi all,

    I am trying to run a command to set a date
    QString currentDate = "date -s "tomorrow""
    #if defined (linux) || defined(FreeBSD)
    int isDateSet= QProcess::execute(currentDate);
    #endif

    This writes the output to console.However i wish to redirect the output to /dev/null.
    In linux command line , I can provide as follows

    date -s "tomorrow" > /dev/null

    But how do I do the same with QProcess::execute()

    Thanks in advance

    Pablo J. RoginaP 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Don't use the static QProcess::execute() function but a QProcess object and read the data from stdout after the finished signal with QProcess::readAllStandardOutput()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      4
      • M Madesh R

        Hi all,

        I am trying to run a command to set a date
        QString currentDate = "date -s "tomorrow""
        #if defined (linux) || defined(FreeBSD)
        int isDateSet= QProcess::execute(currentDate);
        #endif

        This writes the output to console.However i wish to redirect the output to /dev/null.
        In linux command line , I can provide as follows

        date -s "tomorrow" > /dev/null

        But how do I do the same with QProcess::execute()

        Thanks in advance

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Madesh-R you may want to take a look at the documentation regarding communicating via channels

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        M 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          Don't use the static QProcess::execute() function but a QProcess object and read the data from stdout after the finished signal with QProcess::readAllStandardOutput()

          M Offline
          M Offline
          Madesh R
          wrote on last edited by
          #4

          @Christian-Ehrlicher
          Thank you Christian. Will try the same

          1 Reply Last reply
          0
          • Pablo J. RoginaP Pablo J. Rogina

            @Madesh-R you may want to take a look at the documentation regarding communicating via channels

            M Offline
            M Offline
            Madesh R
            wrote on last edited by
            #5

            @Pablo-J-Rogina

            Thanks for the link Pablo, Will certainly take a look at it .

            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