LoginSignup
2
1

More than 5 years have passed since last update.

スクリプト言語で Unix かどうかをチェックする

Last updated at Posted at 2012-11-25

uname 等が不便なことがあります。
そこで /dev/null の存在をチェックします。
念のためデバイスであることも確認します。
原理的に Python 以外のスクリプト言語に応用可能です。

unixcheck.py
from stat import S_ISCHR
from os import stat

def unixcheck():
    try:
        return S_ISCHR(stat('/dev/null').st_mode)
    except:
        return False
2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1