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. QProcess and environment
Forum Updated to NodeBB v4.3 + New Features

QProcess and environment

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k 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.
  • T Offline
    T Offline
    tombough
    wrote on last edited by
    #1

    Hello

    My question: how can I have a process executed within the user's default bash environment? Currently, if I open a terminal, the correct program launches due to paths exported from .bash_profile. However, this is not the case when executing the command via QProcess. Similarly, if I have aliases under .bash_profile or .bashrc, they are not recognized when executed directly by a process. I have also attempted to launch a shell first and execute the alias within that, but again the alias was not recognized:
    @
    process.start("bash");
    process.waitForStarted();
    process.write("foo test.py\n");
    process.write("exit\n");
    process.waitForFinished();
    @
    where alias foo='/Library/Frameworks/Python.framework/Versions/2.6/bin/python' is defined in .bashrc.

    The motivation:
    I am using QProcess to launch a python script from within Qt. As the script requires the import of certain modules, I would like to simply call the command 'python' and make it the users responsibility that the correct version of python is called (with other fixes to come later). Solving this will be of use in other projects as well - basically whenever I want to assume a program is installed without hunting for it.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      I can't remember offhand, but with using bash in this scenario, do you need to pass in a -i or -l flag? I know bash has rules about which config files are read based on whether it's an interactive, a login, or non-interactive shell. (See man bash for more info.)

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      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