0

I'm using os.tmpname() from the standard library, but I'm looking for a better solution.

Mead
  • 100
  • 10
  • define "better". there are multiple ways to achieve that. none of the is particularly nice. if you want the version as well you won't come around running some cli command. if you just want to distinguish between Windows and Unix your approach is probably sufficient. you could also evaluate package.path for example. if you want to do it without the os library – Piglet May 04 '21 at 10:14

1 Answers1

0

On linux i am use...

> os.execute('uname -a')
Linux osmc 4.19.122-2-osmc #1 PREEMPT Sat Jul 4 04:30:20 UTC 2020 armv6l GNU/Linux
true    exit    0
-- armv61 = CPU = Raspberry first generation

With the 3 return values ( true exit 0 ) you can conditionally decide what to do.

A falsy example...

> os.execute('ver')
sh: 1: ver: not found
nil     exit    127
koyaanisqatsi
  • 2,585
  • 2
  • 8
  • 15