Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6798213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:42:11+00:00 2026-05-26T18:42:11+00:00

I have an XML that contains information about environment variable to set into the

  • 0

I have an XML that contains information about environment variable to set into the shell by my python script. Here is a snippet of the XML :

<envVar name='QTDIR'>/homeqt/libs.qt4/qt4.5.1</envVar>
<envVar name='MAKE'>which make</envVar>

This part of this snippet tells my python script to set environment variables QTDIR and MAKE.

My concern is the difference how i have to set the above variables. I know that i can use os.environ to set environment variables and do something like this :

os.environ['QTDIR'] = "/homeqt/libs.qt4/qt4.5.1"

But i can’t use this to set my MAKE variable, i have to execute the command “which make” (to get the path of make executable). My goal is to use the same method/function to set every variables.

SO, i thought to do something like this:

Popen("QTDIR=/homeqt/libs.qt4/qt4.5.1 ; export QTDIR", shell=True, stdout=PIPE, stderr=PIPE)
Popen("MAKE=which make ; export MAKE", shell=True, stdout=PIPE, stderr=PIPE)

But if i do this, the variable will be set only for the subprocess, not for the current shell.

So, my question is, is there a way to do what i want? I DON’T want to analyse the XML and do something like this :

(pseudocode)

if QTDIR has normal value
    os.environ['QTDIR'] = "/homeqt/libs.qt4/qt4.5.1"
if MAKE has value to be executed
    p = Popen("which make", shell=True, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate()
    os.environ['MAKE'] = stdout
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:42:12+00:00Added an answer on May 26, 2026 at 6:42 pm

    I would make use of XML attributes.

    <envVar name="MAKE" type="command">which make</envVar>
    <envVar name="QTDIR" type="string">/homeqt/libs.qt4/qt4.5.1</envVar>
    

    pseudocode depending on your xml library:

    if node.attributes['type'] == 'command':
        value = os.popen(node.firstChild.text).read()
    elif node.attributes['type'] == 'string':
        value = node.firstChild.text
    os.environ[node.attributes['name']] = value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script that parses an XML file that contains part information
I have a problem. I have an XML file that contains information about 100
Situation: I have a simple XML document that contains image information. I need to
I have a buggy xml that contains empty attributes and I have a parser
I have an xml file that contains its element like <ab:test>Str</ab:test> When I am
Me again... I have an XML File that contains different categories which I would
I have an XML file format that contains a structure of questions: <question id=q101>
Let's say I have an existing trivial XML file named 'MyData.xml' that contains the
For an XML file I am creating I have data that contains a bullet
I have an XML file ( XML file I produce ) which contains information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.