Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'attribute': 0.05; 'defines': 0.07; 'skip:/ 10': 0.07; 'subject:file': 0.07; 'variables.': 0.07; 'python': 0.09; 'inherited': 0.09; 'python:': 0.09; 'script,': 0.09; 'cc:addr :python-list': 0.10; '(before': 0.16; 'contents:': 0.16; 'entries,': 0.16; 'sees': 0.16; 'url:unix': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'shell': 0.18; 'are.': 0.22; 'produces': 0.22; 'runs': 0.22; 'cc:2**0': 0.23; 'comment:': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'run': 0.28; 'environment': 0.29; 'running.': 0.29; 'them?': 0.29; 'skip:_ 10': 0.29; 'whatever': 0.35; 'jason': 0.35; 'process,': 0.35; 'pm,': 0.35; 'add': 0.36; 'url:org': 0.36; 'anything': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'gives': 0.39; 'received:192': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'most': 0.61; 'first': 0.61; 'url:blogspot': 0.64; 'url:10': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; '100': 0.78; 'hand': 0.82; 'irrelevant': 0.84; 'running,': 0.84; 'thing,': 0.84; 'url:2007': 0.84 Date: Sun, 30 Sep 2012 20:58:15 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Jason Friedman Subject: Re: parse an environment file References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:agE/OUydIbhZhToScaX92Q78u6yXK2/0hseNvjiS5Gq KKAb02x9lkJ1nYFwE0xhCLBoUVF6+bylG8tg2X1Uy97WKxFJLc DA7hwT/2HsGQ9Jy8dNhhzNYSixwayRD2Cn8liMQoYVY92NkWRY jfA2zjZtyRAPewDqbsGC7Lz77DLqm8nWaHvIhS/VgafLDLcYSm ajnbC86cBV/KEr67+OXEUOjf9clunQs6OtdEErNLtusfp/X4tb O+LBl42vz9oGEzp3G7z51r5ukcTJxoj7uhsSxKrUUmw3yzBnaA IpkvkolyHHTjDV04xvF3aShXkxYMVPvj0HDBE1cIni2tgS4XQ= = Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349053129 news.xs4all.nl 6968 [2001:888:2000:d::a6]:40620 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30578 On 09/30/2012 08:11 PM, Jason Friedman wrote: First comment: I don't know anything about an "environment file." An environment is an attribute of a process, and it's inherited by subprocesses that process launches. This is not a Python thing, it's an OS thing, for whatever OS you're running. > $ crontab -l > * * * * * env > > This produces mail with the following contents: > > HOME=/home/spjsf > LOGNAME=spjsf > PATH=/usr/bin:/bin > PWD=/home/spjsf > SHELL=/bin/sh > SHLVL=1 > USER=spjsf > _=/usr/bin/env In other words, these are the environment variables that cron has, and that it gives to any children it launches. > On the other hand > > $ env > > produces about 100 entries, most of which are provided by my .bashrc; > cron provides only a limited number of environment variables. Gee, those are variables specific to a particular (bash) shell, so how would a program launched by cron know about them? > I want my python 3.2.2 script, called via cron, to know what those > additional variables are. How? You'd have to change the environment that cron sees (before login), or add to the crontab, or /etc/default/cron, or else run some shell from cron that defines those variables and then runs the application. The way to do this is specific to whatever OS you're running, and is irrelevant to Python. Try googling. For some examples, none of which use Python: http://www.perlmonks.org/?node_id=624540 http://www.unix.com/solaris/164483-environment-variables-cron.html http://www.computing.net/answers/unix/how-to-set-environment-variable/5689.html http://linuxshellaccount.blogspot.com/2007/10/crontab-and-your-environment.html -- DaveA