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
process_.clearArguments();
process_.addArgument("cmd");
process_.addArgument("/C");
process_.addArgument("type " + anyfile);
QProcess process_;
process_.clearArguments();
process_.addArgument("cmd");
process_.addArgument("/C");
process_.addArgument("type " + anyfile);
To copy to clipboard, switch view to plain text mode
or even this (path omitted for brevity)
process_.clearArguments();
process_.addArgument("php");
process_.addArgument("-h");
QProcess process_;
process_.clearArguments();
process_.addArgument("php");
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
<?php
//$line = trim(fgets(STDIN));
echo "foo";
fprintf(STDOUT, "%s", "bar");
?>
<?php
//$line = trim(fgets(STDIN));
echo "foo";
fprintf(STDOUT, "%s", "bar");
?>
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)
process_.clearArguments();
//process_.addArgument("cmd"); //command interpreter makes no difference
//process_.addArgument("/C");
process_.addArgument("php");
process_.addArgument("test.php");
//process_.addArgument("php test.php"); //no matter if 1 or 2 args
QProcess process_;
process_.clearArguments();
//process_.addArgument("cmd"); //command interpreter makes no difference
//process_.addArgument("/C");
process_.addArgument("php");
process_.addArgument("test.php");
//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.
Bookmarks