A process running problem
-
Created a function to run a process
QString PROC_Run(QString proc_name, QString proc_args) { QProcess proc; QStringList params; QString out; params << proc_args; proc.start(proc_name, params); proc.waitForFinished(-1); out = proc.readAll(); return out; }
and a test
uint32_t COMMANDS::Process(uint32_t argc, char** args) { uint32_t i; QString params; if (argc < 2) return MSG_MIS_ARG; for (i = 2; i < argc+1; i++) { params += QString::fromLatin1(args[i]) + " "; } msg = PROC_Run(args[1], params); Print(msg + "\r"); return MSG_OK; }
Now I check the script is good
python3 /home/pi/Documents/camera.py image
It's good.So I try to run with a function
proc /usr/bin/python3 /home/pi/Documents/camera.py image
It gives me no errors but the script isn't running. Checked with a break point, all parameters passed right.What can be a problem?
-
@jenya7 said in A process running problem:
for (i = 2; i < argc+1; i++)
{
params += QString::fromLatin1(args[i]) + " ";
}msg = PROC_Run(args[1], params);
Why are you concatenating all parameters to a string?!
Parameters need to be passed as QStringList to QProcess as you can clearly see in documentation. -
@jsulm said in A process running problem:
@jenya7 said in A process running problem:
for (i = 2; i < argc+1; i++)
{
params += QString::fromLatin1(args[i]) + " ";
}msg = PROC_Run(args[1], params);
Why are you concatenating all parameters to a string?!
Parameters need to be passed as QStringList to QProcess as you can clearly see in documentation.I pass it in the function
QStringList params; params << proc_args;
-
@jenya7 said in A process running problem:
I pass it in the function
I know. But it does not change anything!
You putt ALL parameters into ONE string!
Please do it correctly and pass all parameters as a QStringList. Each parameter needs to be one entry in QStringList. Please, this is shown in the documentation... -
@jsulm said in A process running problem:
@jenya7 said in A process running problem:
I pass it in the function
I know. But it does not change anything!
You putt ALL parameters into ONE string!
Please do it correctly and pass all parameters as a QStringList. Each parameter needs to be one entry in QStringList. Please, this is shown in the documentation...Thank you. This way it works.