openSUSE Forums > Programming/Scripting » Identifying the OS

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
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-Sep-2009, 19:07
Puzzled Penguin
 
Join Date: Sep 2009
Posts: 3
dizwell hasn't been rated much yet
Default Identifying the OS

I have a script I want to run only on openSUSE 11.1. So I include this bit of code in the script:

Code:
VERCHECK=`grep 11.1 /etc/SuSE-brand > /dev/null; echo $?`
if [ "$VERCHECK" -eq "1" ]; 
  exit 1
fi
...so the script exits if the string "11.1" is NOT found in that file.

Two questions. The SUSE-brand file actually contains the contents

openSUSE
VERSION = 11.1


How would one go about checking for both lines in a single test. I know, in other words that I could grep for "openSUSE" and then, if that succeeds, nest another grep for "11.1". But if I didn't want to nest grep tests?

Secondly, and a bit cheekily I realise, but what are the *exact* contents of the equivalent file on Suse Enterprise Linux, please (if anyone here knows, of course!)?

Thanks in advance for any help offered.
Reply With Quote
  #2 (permalink)  
Old 03-Sep-2009, 19:36
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,220
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Identifying the OS

You could instead look at /etc/SuSE-release which contains this:

Quote:
openSUSE 11.1 (x86_64)
VERSION = 11.1
on a 64-bit machine for example. Both the distro and version are on the first line.
Reply With Quote
  #3 (permalink)  
Old 03-Sep-2009, 19:42
Puzzled Penguin
 
Join Date: Sep 2009
Posts: 3
dizwell hasn't been rated much yet
Default Re: Identifying the OS

Wonderful advice. I looked in the /etc directory until my eyes went square... and they obviously did! Thank you for that.

Do you, by any chance, happen to know the contents of the SLES equivalent of that file?? No worries if not: you've already helped alot!
Reply With Quote
  #4 (permalink)  
Old 03-Sep-2009, 20:16
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,220
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Identifying the OS

Ask in the SLES forum perhaps?
Reply With Quote
  #5 (permalink)  
Old 03-Sep-2009, 20:30
Explorer Penguin
 
Join Date: Apr 2009
Posts: 678
ab@novell.com hasn't been rated much yet
Default Re: Identifying the OS

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

/etc/SuSE-release from SLES 10 SP2 x86_32:

ab@mybox0:~> cat /etc/SuSE-release
SUSE Linux Enterprise Server 10 (i586)
VERSION = 10
PATCHLEVEL = 2

and from SLES 11 x86_64

ab@mybox1:~> cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0

ab@mybox1:~> cat /etc/SuSE-brand
SLES
VERSION = 11
CO-BRANDS = SLE openSUSE

But yes, this is a good question for the SLES forums specifically in the
future.

Good luck.





ken yap wrote:
> Ask in the SLES forum perhaps?
>
>

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

iQIcBAEBAgAGBQJKoG2oAAoJEF+XTK08PnB5NT4P/im757CcWfZdi36lHucU6XtG
ooGH2ah2hax8UQzlU+lGp0F2ZkdiTBscpJT1jEkTxYXHKZjSzx haUZvu10FRuUzs
zb3TIC8JHmFOB2pOGrk5hati2dlXQQ4e+eCRMqIfpSidNISqkH f7VJAJosLx0VZX
OZhB61/a8RgNjpz9Y11nI8sj7AtTpJ6BbxkpsP/BUhWikcqLpujdTvuEILObDM40
wql++Z/eq4qNMynPrEb4/WHTSB8wwxed/ZCNA7SRwbUUFiG47QR4y/xeP8SjiFNo
lT9NIclr/bDneJjI1LkDoP6rDmwQqdsgrvNaO6kuHQwaeFegrZqBAag63Ej sBkOs
XNwvT2RDSmL7kUodFl318eVcNLpNJhjdJj3BbAQZ/sKZzHfHPx+NaAozXGA45M61
dJoc/YtejToWLFG6NJuBBqzE8B+95vzvHnoNd3ntxNFJxN9FJlXJRlW Qknc+BoV6
8q43sNuF0BSxQH7QnSHmgSNQPZlMMw5D+HldgYLoB+f48aRCN9 xJd/W+j3lZ2i+T
7+pWvWBeO44BRe6XjeGm67MnQeG81vOHjT6j3vUNJnOo3mrgoU ndwF1LuVYCfC6O
/ccnP4xHdFvplaiawixKtsXKRXsRtG+KNTBmo7Z9dRdpX7yihRd m823WngkbCG7K
Bg7UGUs24cJSgEenIZhK
=cjNK
-----END PGP SIGNATURE-----
Reply With Quote
  #6 (permalink)  
Old 03-Sep-2009, 20:39
malcolmlewis's Avatar
Global Moderator
 
Join Date: Jun 2008
Location: Podunk
Posts: 4,673
malcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputation
Default Re: Identifying the OS

Quote:
Originally Posted by ab@novell.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

/etc/SuSE-release from SLES 10 SP2 x86_32:

ab@mybox0:~> cat /etc/SuSE-release
SUSE Linux Enterprise Server 10 (i586)
VERSION = 10
PATCHLEVEL = 2

and from SLES 11 x86_64

ab@mybox1:~> cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0

ab@mybox1:~> cat /etc/SuSE-brand
SLES
VERSION = 11
CO-BRANDS = SLE openSUSE

But yes, this is a good question for the SLES forums specifically in the
future.

Good luck.
Hi
I use this in my signature script;
Code:
lsb_release -sd |cut -f2 -d ""\"
--
Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.2 Milestone 6 (i586) Kernel 2.6.31-rc7-4-desktop
up 10:28, 2 users, load average: 0.11, 0.12, 0.36
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Reply With Quote
  #7 (permalink)  
Old 03-Sep-2009, 21:21
Puzzled Penguin
 
Join Date: Sep 2009
Posts: 3
dizwell hasn't been rated much yet
Default Re: Identifying the OS

Am very grateful for the SLES information (and, as I said, I realise I was being a bit cheeky). Great to know, anyway!

Thank you everyone.
Reply With Quote
Reply

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