Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Executing a Bash Script using QProcess does not work
Forum Updated to NodeBB v4.3 + New Features

Executing a Bash Script using QProcess does not work

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 403 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • supergS Offline
    supergS Offline
    superg
    wrote on last edited by superg
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        path problem. set the path to ssconvert or use explicit pathto executable from within the script.

        I light my way forward with the fires of all the bridges I've burned behind me.

        1 Reply Last reply
        0
        • supergS Offline
          supergS Offline
          superg
          wrote on last edited by
          #4

          thank you both, now it works!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved