[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Detecting the operating system?
- From: Asko Kauppi <askok@...>
- Date: Thu, 28 Jun 2007 09:54:43 +0300
See my Hamster and/or Lumikki projects on the net. They detect the
OS based on 'uname' and environment variables, which has proven to be
harmless, accurate and extensible.
Frank Küster kirjoitti 27.6.2007 kello 22:49:
I'd like to detect in a lua script on which (kind of) operating system
I'm running, in order to provide sensible defaults for calls to
programs (viewers, actually). Thinking about OS X, I considered
if os.execute('nothere 2>/dev/null') / 256 == 127 then
print("does not exist")
and got the answer
/dev/null works on UNIX, on Windows it's nul (and does not appear in
the filesystem). However, another nice solution would be to walk
through the path (os.getenv("PATH")). With other words, write a
function which does the same as the UNIX which command.
Note that paths are separated by ";" on Windows instead of ":".
Which brings me to the question, is there some code snippet which I
Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie,
Debian Developer (teTeX/TeXLive)