openSUSE Forums > Programming/Scripting » How do I get distro-info

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
Page 1 of 2 1 2
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-Nov-2009, 03:32
Puzzled Penguin
 
Join Date: Aug 2009
Location: Värmland, Sweden
Posts: 21
freefox hasn't been rated much yet
Question How do I get distro-info

Are there some command line tool that shows distro and version of distro?

I would like to
Code:
#!/whatever shell 
if (opensuse)
  # stuff
elseif (ubuntu)
  # other stuff
endif
__________________
| openSUSE 11.2 | gnome | laptop: asus x5dij | intel core 2 duo t5900 | 64 bit | screen: 15,6" WXGA Glare LED (1366x768) | graphic: Intel GMA 4500 | HSDPA USB modem - HUAWEI E220 |
Reply With Quote
  #2 (permalink)  
Old 06-Nov-2009, 03:55
TaraIkeda's Avatar
Parent Penguin
 
Join Date: Feb 2009
Posts: 728
TaraIkeda hasn't been rated much yet
Default Re: How do I get distro-info

Well why use commandline when both Ubuntu and openSUSE offer a gui to identify the version?
Reply With Quote
  #3 (permalink)  
Old 06-Nov-2009, 03:56
ram88's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: relative
Posts: 1,169
ram88 hasn't been rated much yet
Send a message via MSN to ram88 Send a message via Skype™ to ram88
Default Re: How do I get distro-info

Code:
cat /etc/SuSE-release
will display you the architecture and the version.
__________________
http://akoskm.blogspot.com/
http://yami.googlecode.com/

Do not login directly as root - Thank you!
Reply With Quote
  #4 (permalink)  
Old 06-Nov-2009, 04:15
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,898
hcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enough
Default Re: How do I get distro-info

Code:
smweb@boven:~> cat /etc/SuSE-release
openSUSE 10.3 (i586)
VERSION = 10.3
smweb@boven:~>
__________________
Henk van Velden
Reply With Quote
  #5 (permalink)  
Old 06-Nov-2009, 04:17
hcvv's Avatar
Wise Penguin
 
Join Date: Jun 2008
Location: Netherlands
Posts: 1,898
hcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enoughhcvv 's reputation will be famous soon enough
Default Re: How do I get distro-info

Quote:
Originally Posted by TaraIkeda View Post
Well why use commandline when both Ubuntu and openSUSE offer a gui to identify the version?
And how is he suposed to use that information in the rest of his script?
__________________
Henk van Velden
Reply With Quote
  #6 (permalink)  
Old 06-Nov-2009, 05:43
Puzzled Penguin
 
Join Date: Aug 2009
Location: Värmland, Sweden
Posts: 21
freefox hasn't been rated much yet
Default Re: How do I get distro-info

I tried to illustrate that with my psedo code block.
Depending on distro I would like different things to execute.
__________________
| openSUSE 11.2 | gnome | laptop: asus x5dij | intel core 2 duo t5900 | 64 bit | screen: 15,6" WXGA Glare LED (1366x768) | graphic: Intel GMA 4500 | HSDPA USB modem - HUAWEI E220 |
Reply With Quote
  #7 (permalink)  
Old 06-Nov-2009, 05:46
Puzzled Penguin
 
Join Date: Aug 2009
Location: Värmland, Sweden
Posts: 21
freefox hasn't been rated much yet
Default Re: How do I get distro-info

Thanks. That solves the suse part. But I would like a more generic solution, telling which distro it is too. suse or ubuntu or ...

More ideas, please.
__________________
| openSUSE 11.2 | gnome | laptop: asus x5dij | intel core 2 duo t5900 | 64 bit | screen: 15,6" WXGA Glare LED (1366x768) | graphic: Intel GMA 4500 | HSDPA USB modem - HUAWEI E220 |
Reply With Quote
  #8 (permalink)  
Old 06-Nov-2009, 06:26
FeatherMonkey's Avatar
Wise Penguin
 
Join Date: Mar 2008
Posts: 1,545
FeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura about
Default Re: How do I get distro-info

Not sure there is a more generic though neither am I sure you can just rely on this. cat /etc/*-release really should work but what if for some reason it is empty? Any way this has some and has a few suggestions at some wildcards that may catch most.

release-files
__________________
Man first, have a try at Info, have a look at Wiki, if all that fails Scroogle!!!!!
If I've helped click on the Rep button I don't know what it does but it sounds cool.
Reply With Quote
  #9 (permalink)  
Old 06-Nov-2009, 06:32
Explorer Penguin
 
Join Date: Apr 2009
Posts: 676
ab@novell.com hasn't been rated much yet
Default Re: How do I get distro-info

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If the aforementioned file exists, then SUSE. If not, then test for
something Ubuntu-specific. What that is, though, is probably something to
be found in an Ubuntu forum. A quick Google search as follows:

ubuntu version command line

turned up several hits that answered the question (`cat /etc/issue`) which
also works on my SUSE box so maybe that is a better distribution-agnostic
way to get which distro you are on.

Good luck.





freefox wrote:
> Thanks. That solves the suse part. But I would like a more generic
> solution, telling which distro it is too. suse or ubuntu or ...
>
> More ideas, please.
>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJK9BdsAAoJEF+XTK08PnB5xqAP+QGn7fG/1F3j4t9FQrRw60yL
CPXizU9whWYICqGbqtfVoKq/F8LN1yv4+2JAwL5vtsVHJZwTZts2oOCDI3ddRZ50
mZuKkFTeTXCWjlsQA1HPvI7I03MZpy69s0Qxsm1Eo8lBIIh/IS2q2fkWuWKnObjt
CVNGB317iW0aAato69BfRrMuQcGNfKwMKrnrk9lgo5HRWjOPTp bDwk3QEEYFpv4x
oE1j+fZ3xDnGjB7p/VIhHjxVA+hYnk3NL/CGAkz2jlvSfSkHp8DQDK2x1M6omgyB
+5yG4xBR+ahMh4PIsuv+xHIOxqtoUWT2AvuEnSMJkW74vz+c3L E2E6/J7qrE+Oaa
+GvLh92CaYFYjd3ypxVN9WsNQaqUGfMDjhukHbuZTW6gTXIjKn +Lyu1B3efYdQyo
9LDE6HyRe3uVCTguTDLh/1TG8IgiqfYrKs3o+IYORqUirgyT2+mtXAR86pO6LOv0
vz6mXrTSG5+e66QPyf605AeOSIwmOhZXFL7N0A0ZAWwsBNND82 NlnS6b+0mMS98/
hNJsfyfYHIfQN4j2HX6DcNKiPNw/EtXtvhN7ipuK9kEMc7+4/wEOaTS7/qnXMjm7
hHkZDHydaeTnJWmlA1bH009L/2ZFj6e9/mp8sx1+5lqUNTIiJfwuPo5rm8Eyxbab
QnL+1HocqXZOTAZUikqF
=gq5k
-----END PGP SIGNATURE-----
Reply With Quote
  #10 (permalink)  
Old 06-Nov-2009, 06:33
malcolmlewis's Avatar
Global Moderator
 
Join Date: Jun 2008
Location: Podunk
Posts: 4,640
malcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputation
Default Re: How do I get distro-info

Quote:
Originally Posted by freefox
Thanks. That solves the suse part. But I would like a more generic
solution, telling which distro it is too. suse or ubuntu or ...

More ideas, please.
Hi
Use the lsb_release command eg in my sig I use;
Code:
MYSYSTEM=`lsb_release -sd |cut -f2 -d ""\"`
--
Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.37-0.1-default
up 3 days 9:12, 2 users, load average: 0.03, 0.09, 0.05
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.18

Reply With Quote
Reply
Page 1 of 2 1 2

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2