file log output script execution windows not created on Windows
-
@JonB Many thanks for your helpful reply.
But with the code below
m_sCommandQuery = QString("sqlplus %1/%2@%3 @\"%4\\%5\" > %4\\exe_scrip.log ").arg(m_sDbUser, m_sDbPwd, m_sDbName, script_path.replace("/","\\"), script_name); argList << "/c" << m_sCommandQuery; process->start("cmd", argList); process->waitForStarted(); process->waitForFinished(); process->close();
I've the following error
Process finished ==> Error : 'sqlplus' n'est pas reconnu en tant que commande interne ou externe, un programme ex?cutable ou un fichier de commandes.
Note that the path of oracle bin is present in the enviroment variables.
Can you tell me what wrong ?
For the second approch, I've implemented as following
process->setStandardOutputFile(QString("%1\\exec_script_%2.log").arg(script_path.replace("/","\\"), script_name)); argList.clear(); argList << QString("%1/%2@%3 @\"%4\\%5\"").arg(m_sDbUser, m_sDbPwd, m_sDbName, script_path.replace("/","\\"), script_name); process->startDetached("sqlplus", argList); process->waitForStarted(); process->waitForFinished();
but no log file was created.
Can you tell me what wrong and how to fix this.
Really many thanks.
Regards. -
Hi,
For your tests, you should use the full path to the executable. You can check after that the state of the PATH environment variable.
For your paths, use forward slashes in your code and then QDir::toNativeSeparators. That will make things easier to write.
-
@mourad_bilog
Do all things @SGaist says. I don't thinkstartDetached()
is right, it may interfere with either redirection or certainlywaitForFinished()
I would have thought. Test your stuff a bit at a time. The principle of redirection does work. -
Hello,
Many thanks @SGaist, @JonB for your contribution and very helpfull responses.now, the output log is ok. I've juste one thing to resolve. In fact, when running sqlplus without to full path, I've an error that this file is not found or not existing noting that the oracle bin path is indicated in the envirement path.
Can you tell me why I've this error and what I must to change to fix this problem.Many thanks in advance.
Regards. -
@mourad_bilog
How do you run thissqlplus
completely outside of Qt? -
Check the PATH environment variable in the Run part of the Project panel. It likely does not contain the path to sqlplus.
-
@JonB from the Windows bash I run direcly sqlplus without the full path.
Note that, if I test with the sqlcmd (SQL Server) from Qt application, it work fine without the full path.Note that twice pathes are in variables envirenement
-
@mourad_bilog
What directory is thesqlplus
in? How does yourPATH
variable outside of Qt ()"from the Windows bash I run direcly sqlplus" compare to thePATH
when launching your process from within Creator or wherever you run it from? When it does not work viaQProcess
, what have you done about checking for any error and in particular reporting anyprocess->readAllStandardError()
(andreadAllStandardOutput()
)? -
@JonB sqplus is located in
D:\app1\Mouadh\product\11.2.0\dbhome_2\BIN
Here's the %PATH% output from the Windows command bash :
echo %PATH% D:\app1\Mouadh\product\11.2.0\dbhome_2\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jdk1.7.0_09\bin;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
I'm using MS Vistual Studio and readAllStandardError() (and readAllStandardOutput() return the error "not found or not internal /external / batch command" when I call qprocess start.
-
@mourad_bilog
So you can see it is finding it from the very first element in yourPATH
when you execute from " the Windows command bash". I don't know when/where that gets prepended to your PATH? It appears to be the case that your PATH does not have that when you execute it from Creator. @SGaist told you:Check the PATH environment variable in the Run part of the Project panel. It likely does not contain the path to sqlplus.
? Maybe it gets prepended only when you go into bash shell, e.g. some Windows
.bashrc
file. So either you have do the same/run it viabash
as I showed earlier, or you have to put the necessary into that variable in Creator. Also depends whether your application is for your own use only or whether you intend to distribute it to others.