[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Detecting the operating system?
- From: Frank Küster <frank@...>
- Date: Wed, 27 Jun 2007 21:49:56 +0200
Hi,
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 external
programs (viewers, actually). Thinking about OS X, I considered
> if os.execute('nothere 2>/dev/null') / 256 == 127 then
> print("does not exist")
> end
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
could use?
Regards, Frank
--
Frank Küster
Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie, Univ. Zürich
Debian Developer (teTeX/TeXLive)