Results 1 to 3 of 3

Thread: Qt3/Windows: QProcess and php-cli

  1. #1
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt3/Windows: QProcess and php-cli

    Hi all,

    yes, Qt3 and Windows. Pita but can't help it. Hope there's a Qt veteran around...

    Problem in short: Can't read from a php script's stdout.

    At length:
    I have used QProcess often and successfully, and for running php scripts, too.
    But do so and communicate via stdin/stdout is a first.

    From this
    Qt Code:
    1. QProcess process_;
    2. process_.clearArguments();
    3. process_.addArgument("cmd");
    4. process_.addArgument("/C");
    5. process_.addArgument("type " + anyfile);
    To copy to clipboard, switch view to plain text mode 
    or even this (path omitted for brevity)
    Qt Code:
    1. QProcess process_;
    2. process_.clearArguments();
    3. process_.addArgument("php");
    4. process_.addArgument("-h");
    To copy to clipboard, switch view to plain text mode 
    I can read from stdout just fine, connecting to SIGNAL(readyReadStdout()).

    Also, when I execute this "test.php" script from a DOS box
    Qt Code:
    1. <?php
    2. //$line = trim(fgets(STDIN));
    3. echo "foo";
    4. fprintf(STDOUT, "%s", "bar");
    5. ?>
    To copy to clipboard, switch view to plain text mode 
    it writes out "foobar" as expected.

    However, running (again, paths omitted for brevity - QDir::convertSeparators() used but changes nothing)
    Qt Code:
    1. QProcess process_;
    2. process_.clearArguments();
    3. //process_.addArgument("cmd"); //command interpreter makes no difference
    4. //process_.addArgument("/C");
    5. process_.addArgument("php");
    6. process_.addArgument("test.php");
    7. //process_.addArgument("php test.php"); //no matter if 1 or 2 args
    To copy to clipboard, switch view to plain text mode 
    the very same slot that got called before now is never executed.

    I don't even know if it's a QProcess limitation, or a php one, or how I could make sure of one or other.

    Any idea? Thx.

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

    Default Re: Qt3/Windows: QProcess and php-cli

    Make sure your QProcess object doesn't go out of scope before it has a chance to execute the script.
    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.


  3. #3
    Join Date
    Jun 2006
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt3/Windows: QProcess and php-cli

    I have.
    Edit: I put the QProcess object definition there for completeness. In real, it is a member of a parent class which is assured to live on.

    (I vaguely sensed I should've been less brief...)

Similar Threads

  1. QProcess issue with GPG under Windows
    By superpacko in forum Qt Programming
    Replies: 6
    Last Post: 7th September 2011, 21:19
  2. Problem using QProcess on Windows XP
    By shopov in forum Newbie
    Replies: 3
    Last Post: 29th April 2010, 13:28
  3. read stdout with QProcess under Windows
    By jlbrd in forum Qt Programming
    Replies: 4
    Last Post: 1st September 2006, 18:29
  4. need help for QProcess under windows
    By patcito in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2006, 20:54
  5. Qprocess never end in MS windows
    By antonio.r.tome in forum Qt Programming
    Replies: 12
    Last Post: 23rd February 2006, 13:35

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.