Results 1 to 4 of 4

Thread: Command run in terminal but not in QProcess while PATHs are inserted

  1. #1
    Join Date
    Jul 2020
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Angry Command run in terminal but not in QProcess while PATHs are inserted

    Stackoverflow question
    I want to run a command in Ubuntu via Qt using QProcess. My command is fluent3DMeshToFoam <mesh address> and when I run it into terminal its OK and produces sum output and files in a specific location. But I have problem with running it using QProcess.

    I have noticed that I should add the path of fluent3DMeshToFoam to ProcessEnvironment of my QProcess object. So I did:

    Qt Code:
    1. QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    2. env.insert("PATH" , env.value("PATH") + ":"+"<path of fluent3DMeshToFoam>");
    3. myProcess.setProcessEnvironment(env);
    4. myProcess.start("fluent3DMeshToFoam" , QStringList() << "<mesh address>");
    5. myProcess.waitForFinished(-1);
    To copy to clipboard, switch view to plain text mode 
    I connected readyRead()and errorOccurred() signals and after I run, the errorOccurred signal emits and the following error shows:

    execve: No such file or directory

    I searched alot and could not find out where the problem is. thanks.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,563
    Thanks
    254
    Thanked 728 Times in 718 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Command run in terminal but not in QProcess while PATHs are inserted

    If this is Windows, PATH strings are separated by semicolon (';') not colon (':'). Also, if this is Windows, be sure your <path of fluent3dMeshToFoam> is properly escaping backslashes: "C:\\Path\\To\\MeshToFoam". Likewise, be sure that <mesh address> is also escaped if you have an absolute path to the file or if you are specifying just the file name, be sure QProcess thinks that your working directory is the same place you have the file.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2020
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Command run in terminal but not in QProcess while PATHs are inserted

    Thanks but as I mentioned in the post, I'm using Ubuntu not Windows.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,563
    Thanks
    254
    Thanked 728 Times in 718 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Command run in terminal but not in QProcess while PATHs are inserted

    Oops, missed that. Is QProcess running as the same user and group as your terminal window? Are you sure the working directory for QProcess is the same as the location of your mesh file? Have you tried running a different executable, maybe one that doesn't need an input argument?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Sending command to terminal
    By dcasey627 in forum Newbie
    Replies: 3
    Last Post: 4th April 2016, 08:27
  2. Execute command without terminal window
    By RolandHughes in forum Qt Programming
    Replies: 2
    Last Post: 17th June 2015, 09:38
  3. Replies: 3
    Last Post: 23rd February 2011, 08:50
  4. Replies: 7
    Last Post: 15th April 2007, 01:39
  5. call bash/terminal command with QT
    By myta212 in forum Newbie
    Replies: 1
    Last Post: 13th November 2006, 15:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.