[Tutor] *nix-specific Python Scripting

William O'Higgins william.ohiggins at utoronto.ca
Thu May 12 22:08:44 CEST 2005


On Thu, May 12, 2005 at 09:37:03PM +0200, Roel Schroeven wrote:
>William O'Higgins wrote:
>> It is a simple check to see if the X server is running (this is
>> inelegant, but it works - if you have a better way, I'd love to know
>> about it, but I would like to be able to do things like this in Python -
>> so I might better write scripts with it).
>
>Checking for startx doesn't work if the server is started via xdm (or 
>kdm or gdm). Another solution would be to check for the DISPLAY 
>environment variable, though that solution has problems of it's own.

Absolutely true.  However, in this context I can be assured that if X is
running, it was started by startx.  More importantly, the DISPLAY
environment variable is not usually imported into the shell/process
running a script - exporting ENV willy-nilly into sub-processes and
spawned shells is, from a security standpoint, very, very bad.  I could
just as easily look for X itself, which is more foolproof, but I am only
looking to stump a small sub-set of possible fools.  The set of all
fools is said to be unbounded, making proof against them non-trivial.
Still, I appreciate the advice and suggestions.
-- 

yours,

William

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20050512/d122fab8/attachment.pgp


More information about the Tutor mailing list