2

My problem is to get information about the linux distro what is running the mono code(For example: Linux Mint, Ubuntu, Fedora, etc...)

This is important because my application is used to edit .bash_profile(Ubuntu) or .profile(Linux Mint) or .bashrc(Mac OS) files to easily edit environment variables like Rapid Environment Editor on Windows

Environment.OSVersion.Platform does not give me the necessary details, only Unix in my case(I'm using Linux Mint).

4
  • does os.uname() give you enough?
    – isedev
    Feb 27, 2014 at 11:48
  • As far as I know os.uname() is in Python not in Mono. Anyway, os.uname() isn't enough because it says I'm on Ubuntu, which actually false, because I'm on Linux Mint as I mentioned in my question. I think this os.uname() thing occurs because Linux Mint is derivated from Ubuntu Feb 27, 2014 at 12:07
  • Note that the distro doesn't necessarily predetermine the files you mentioned, it depends on what the shell of the user is, and for which scenario you want to set the variables for (ie. login or not login shell).
    – Jester
    Feb 27, 2014 at 14:31
  • Then, what is your suggestion for handling this situation? Maybe I just simply save all added environment variables to all listed files? Maybe It could work but I think this is not elegant. Feb 28, 2014 at 13:12

1 Answer 1

1

I don't know if there's a .NET API to do this. From the looks of it, it seems you're right, Environment.OSVersion will only tell you you're running Unix.

If that first check indicates you're running Unix, perhaps you can try parsing the /etc/lsb-release file. On my machine that file looks like this:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"

You can test if it exists in other modern distros as well.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.