| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
I have a QProcess running perfectly on Linux and OSX and I can't get
it to work on windows:
QProcess* foo= new QProcess( this );
foo->setProcessChannelMode(QProcess::MergedChannels);
QStringList env = QProcess::systemEnvironment();
foo->setEnvironment(env);
foo->start( "dir" );
if( !foo->waitForFinished() ) {
qDebug() << QDir( foo->workingDirectory() ).entryList();
qDebug() << "Fail:" << foo->errorString();
qDebug() << "Exit = " << foo->exitCode();
} else {
qDebug() << "Output:" << foo->readAll();
}
This is a dumbed down example just to see if it works and I'm getting the error:
"Process failed to start"
This is also the same error I get if I try a random string in place of
"dir." So it's clearly not finding "dir" no less the program I
actually want to run. Any help you can give would be great...
Thanks...
Qt 4.3.3 commercial for msvc.net on XP SP2.latest
-Willy
--
[ signature omitted ]
On Fri, Jan 25, 2008 at 04:01:16PM -0800, Willy P wrote:
> This is also the same error I get if I try a random string in place of
> "dir." So it's clearly not finding "dir" no less the program I
> actually want to run. Any help you can give would be great...
> Thanks...
>
As far as I remember "dir" is a build-in command of windows shell
(cmd.exe). so try to launch *real* command ("cmd.exe", "calc", "mspaint"
are good choice). If you want to get "dir" output, read manual about how
to run cmd.exe with some command.
--
[ signature omitted ]
Attachment:
signature.asc
Description: Digital signature
Ok, I got calc to work. dir was a poor choice of test commands. But
I still can't get ffmpeg to work and I'm in the correct directory:
ffmpeg->setWorkingDirectory( "/bin" );
ffmpeg->setProcessChannelMode(QProcess::MergedChannels);
ffmpeg->setEnvironment( QProcess::systemEnvironment() );
ffmpeg->start( "ffmpeg" );
if( !ffmpeg->waitForFinished() ) {
qDebug() << ffmpeg->workingDirectory();
qDebug() << QDir( ffmpeg->workingDirectory() ).entryList();
qDebug() << "Fail:" << ffmpeg->errorString();
qDebug() << "exit = " << ffmpeg->exitCode();
} else {
qDebug() << "Output:" << ffmpeg->readAll();
}
The output is as follows:
"/bin"
(".", "..", "bash.exe", "bashbug", "ffmpeg.exe", "sh.exe")
Fail: "Process failed to start"
exit = 0
Thanks for your help. I'm probably doing something dumb. I just
don't know DOS very well.
-Willy
On Jan 25, 2008 4:11 PM, Dmitry Nezhevenko <dion@xxxxxxxxx> wrote:
> On Fri, Jan 25, 2008 at 04:01:16PM -0800, Willy P wrote:
> > This is also the same error I get if I try a random string in place of
> > "dir." So it's clearly not finding "dir" no less the program I
> > actually want to run. Any help you can give would be great...
> > Thanks...
> >
>
> As far as I remember "dir" is a build-in command of windows shell
> (cmd.exe). so try to launch *real* command ("cmd.exe", "calc", "mspaint"
> are good choice). If you want to get "dir" output, read manual about how
> to run cmd.exe with some command.
>
> --
> WBR, Dmitry
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFHmnqx0T/aIlRaJQYRAg7MAJ92cuMSlwjJjyML+4reZ4FtFhl3ugCgvK/X
> AaNLPJTCPIse7eqDrcnaWz4=
> =8xls
> -----END PGP SIGNATURE-----
>
>
--
[ signature omitted ]
Ok I got it.
"cmd.exe /C ffmpeg"
I thought you were saying you only had to do cmd.exe for built-in
commands. Thanks for you help. Have a great w/e.
-Willy
On Jan 25, 2008 4:50 PM, Willy P <willy.lists@xxxxxxxxx> wrote:
> Ok, I got calc to work. dir was a poor choice of test commands. But
> I still can't get ffmpeg to work and I'm in the correct directory:
>
>
> ffmpeg->setWorkingDirectory( "/bin" );
>
> ffmpeg->setProcessChannelMode(QProcess::MergedChannels);
> ffmpeg->setEnvironment( QProcess::systemEnvironment() );
> ffmpeg->start( "ffmpeg" );
>
> if( !ffmpeg->waitForFinished() ) {
> qDebug() << ffmpeg->workingDirectory();
> qDebug() << QDir( ffmpeg->workingDirectory() ).entryList();
> qDebug() << "Fail:" << ffmpeg->errorString();
> qDebug() << "exit = " << ffmpeg->exitCode();
> } else {
> qDebug() << "Output:" << ffmpeg->readAll();
> }
>
> The output is as follows:
>
> "/bin"
> (".", "..", "bash.exe", "bashbug", "ffmpeg.exe", "sh.exe")
> Fail: "Process failed to start"
> exit = 0
>
> Thanks for your help. I'm probably doing something dumb. I just
> don't know DOS very well.
>
> -Willy
>
>
>
>
> On Jan 25, 2008 4:11 PM, Dmitry Nezhevenko <dion@xxxxxxxxx> wrote:
> > On Fri, Jan 25, 2008 at 04:01:16PM -0800, Willy P wrote:
> > > This is also the same error I get if I try a random string in place of
> > > "dir." So it's clearly not finding "dir" no less the program I
> > > actually want to run. Any help you can give would be great...
> > > Thanks...
> > >
> >
> > As far as I remember "dir" is a build-in command of windows shell
> > (cmd.exe). so try to launch *real* command ("cmd.exe", "calc", "mspaint"
> > are good choice). If you want to get "dir" output, read manual about how
> > to run cmd.exe with some command.
> >
> > --
> > WBR, Dmitry
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.6 (GNU/Linux)
> >
> > iD8DBQFHmnqx0T/aIlRaJQYRAg7MAJ92cuMSlwjJjyML+4reZ4FtFhl3ugCgvK/X
> > AaNLPJTCPIse7eqDrcnaWz4=
> > =8xls
> > -----END PGP SIGNATURE-----
> >
> >
>
--
[ signature omitted ]
Hi, > Ok I got it. > > "cmd.exe /C ffmpeg" > > I thought you were saying you only had to do cmd.exe for built-in > commands. Thanks for you help. Have a great w/e. I think you were correct in the first place: cmd.exe is needed for built-in cmd.exe commands, but it shouldn't be needed for real programs such as ffmpeg. What if you provide the full path to ffmpeg? The working directory may not be in the path. -- [ signature omitted ]
Willy P wrote: > ffmpeg->start( "ffmpeg" ); ".exe" is missing. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
All the debugging code I put in there was to prove that QProcess was in the correct working directory, though I don't think I ever tried a full path for ffmpeg. QProcess (or windows) doesn't seem to care about the .exe. I definitely tried every variation when I was trying to get it to work. I'm happy with an ugly #ifdef for the windows side but I definitely don't understand why either the working directory doesn't count for executables in QProcess or why windows needs to be told to use it's own shell to execute shell commands. Either way, it works as it is. If anyone can further my limited understanding of either QProcess or Windows internals I would be grateful. Thanks to all who chimed in... -Willy On Jan 26, 2008 12:27 AM, Thiago Macieira <thiago.macieira@xxxxxxxxxxxxx> wrote: > Willy P wrote: > > ffmpeg->start( "ffmpeg" ); > > ".exe" is missing. > -- > Thiago José Macieira - thiago.macieira AT trolltech.com > Trolltech ASA - Sandakerveien 116, NO-0402 Oslo, Norway > -- [ signature omitted ]
On Sun, Jan 27, 2008 at 11:33:05PM -0800, Willy P wrote: > I'm happy with an ugly #ifdef for the windows side but I definitely > don't understand why either the working directory doesn't count for > executables in QProcess or why windows needs to be told to use it's > own shell to execute shell commands. This is just because there are could be no "exe" files for some shell commands like "dir", "cd". Unixes has such examples too, however currently I can't provide any example except "ulimit" command, which has no executable binary in $PATH. Also hopping that target executable (for example ffmpeg) will be in Working directory is _not_ so good idea (just my IMHO, nothing more). Don't forget that even on Windows platform app _can_ be launched in non-application directory, so app will be unable to locate external app. As for me correct crossplatform way without #ifdef's is specifying full path to executable (at least for commercial projects, when all required depenedencies are provided in single tarball). It can be retrieved by QCoreApplication :: applicationDirPath(). On Windows you can just place ffmpeg to application directory and it will work correctly. On Unix app will access ffmpeg from same directory as argv[0]. This will work for installations in /usr/local/bin as well as for M$-style (like /opt/mycoolapp). -- [ signature omitted ]
Attachment:
signature.asc
Description: Digital signature