Executing a Bash Script using QProcess does not work
-
Hi, I created a bash script to convert a .csv file to .xslx using the following command:
ssconvert $1 $2.xlsx
Where $1 is my .csv file and $2 is the name I want the .xlsx file to have.
I have tried the following code with no luck.nroEnsayo = 300; QProcess toXlsxScript; QStringList arguments; QString csvFile("/Users/santiagocarlos/Trabajo/Polarímetro/Exports/" + QString::number(nroEnsayo) + ".csv"); QString name(QString::number(nroEnsayo)); QProcess::startDetached("/bin/bash", QStringList() << "-c" << QString("/Users/santiagocarlos/Trabajo/Polarímetro/Exports/csvToExcel.sh %1 %2").arg(csvFile, name));
Where csvFile contains the path to my .csv file ($1 in the script) and name is the name I want for the .xlsx file ($2 in the script).
When executing this code, I get the following error:/Users/santiagocarlos/Trabajo/Polarímetro/Exports/csvToExcel.sh: line 3: ssconvert: command not found
But the script works perfectly outside of Qt. Does anyone know what the problem is?
If so, does anyone know an alternative to converting a .csv file to xlsx on Qt? I think that simply changing the file format does the trick, but haven't tried it yet, and I read that it displays an error message, so I'd like to avoid that.
Thank you all in advance. -
But the script works perfectly outside of Qt. Does anyone know what the problem is?
Best guess is that the shell you run the script from outside Qt has
ssconvert
(from Gnumeric?) in the PATH and that the runtime environment the Qt program has does not.If you are launching the program from Qt Creator then the Project settings govern the environment it receives.
-
path problem. set the path to ssconvert or use explicit pathto executable from within the script.