[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lua-l
Subject:    Re: Detecting the operating system?
From:       Asko Kauppi <askok () dnainternet ! net>
Date:       2007-06-28 6:54:43
Message-ID: BD78A24D-9C94-4354-ACFC-FBC8CA07177C () dnainternet ! net
[Download RAW message or body]


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.

http://luaforge.net/projects/lumikki/

http://luaforge.net/projects/hamster/


Frank Küster kirjoitti 27.6.2007 kello 22:49:

> 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)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic