On 26/02/16 04:49, Aneeque Khan wrote:
> The problem is that virtually any method of running a shell script
> will involve starting a separate process and setting the variables in
> that process' environment. So far as I can tell the only way to do
> what you want would be to run your shell script first then launch your
> python script from the shell script. That would mean breaking your
> current python script in two, and if you do a lot of work prior to
> launching the shell, that's probably not practical. 

Is it possible to adopt the approach described above?
Can you split your Python processing into two(or more)
parts, one before and one after the shell  script?
That will be the easiest way I suspect.

> I have recently started with python, can you direct me how we can achieve
> this by parsing the shell as a text file.

While parsing a shell script is not impossible, especially since you are
only
looking to trap the environment variables it's far from trivial.
Especially for
a beginner. I'd treat that as a last resort.

Also if the shell script does more than just set the variables its not
going
to work since you still need to run the script.

Do you have any control of the shell script content?
Or is that generated outside of your influence?
If you can control it you might be able to get the script to
dump it's environment vars to a temp file and read that.

The next question is what do you plan on doing with these once you
have them? They won't be of any value to the shell script or any other
script unless you set them again locally? Or are the just path locators?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to