LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 05-12-2014, 03:02 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Linux version


I would like my scripts to be able to work with different versions of Linux.

I have Puppy Slacko 5.6 installed, but uname is showing something different.

From uname

Linux 3.10.5 i686

From Pup Sysinfo.

Distro: Slacko Puppy 5.6.0

I also tried cat /proc/version
 
Old 05-12-2014, 07:29 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,349
Blog Entries: 28

Rep: Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147
uname is showing the kernel version, not the OS version. cat /proc/version also outputs the kernel version.

For example, on my Debian Sid system, uname -a outputs this:

Code:
:~$ uname -a
Linux tuna 3.12-1-686-pae #1 SMP Debian 3.12.9-1 (2014-02-01) i686 GNU/Linux
meaning kernel v. 3.12.9-1.

In contrast,

Code:
~$ cat /etc/*release*    
PRETTY_NAME="Debian GNU/Linux jessie/sid"
NAME="Debian GNU/Linux"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

Last edited by frankbell; 05-12-2014 at 07:34 PM.
 
Old 05-12-2014, 10:04 PM   #3
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
cat /etc/*release*
gave this:

Quote:
cat: /etc/*release*: No such file or directory
 
Old 05-13-2014, 01:04 AM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Within reason it should not matter which kernel version or which distribution or version of that is running for a script to work. But it depends what you want the script to do?
 
Old 05-13-2014, 01:19 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Fixit7 View Post
I would like my scripts to be able to work with different versions of Linux.
Great, IMHO, it's a good idea to make your scripts portable. Do you have any questions related to this?

Cheers,

Evo2.
 
Old 05-13-2014, 01:22 AM   #6
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks.

For my needs, it does matter.

There are are many distros of Linux.

And each of them have different commands.

And that is what makes all of them unique.

Andy
 
Old 05-13-2014, 01:44 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by Fixit7 View Post
There are are many distros of Linux.

And each of them have different commands.

And that is what makes all of them unique.
Ok, so you are concerned about the presence or absence of a command? If so, the normal approach is normally testing for the existence (and possibly behaviour) of that command, not trying to determine the exact operating system version. If you tell us what you are actually trying to achieve, and then ask related questions, I think you'll probably get more useful answers.

Evo2.
 
Old 05-13-2014, 11:16 AM   #8
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,541

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
Quote:
cat: /etc/*release*: No such file or directory
You could try: cat /etc/issue

Some Linux distributions have a release file, some have an issue file and some have both.
 
Old 05-13-2014, 01:27 PM   #9
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
# cat /etc/issue
Slacko Puppy Linux
Linux 3.10.5 [i686 arch]
 
Old 05-13-2014, 05:19 PM   #10
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

once more, do you really care what distro and version your script is running on? There are literally thousands. Please tell us what you are actually trying to achieve and we may be able to help.

Evo2.
 
Old 05-13-2014, 06:40 PM   #11
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,143
Blog Entries: 21

Rep: Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481Reputation: 3481
Inxi works with different versions of Linux

Code:
# inxi -Fxz
System:    Host: biker Kernel: 3.10.32 i686 (32 bit gcc: 4.7.1) 
           Desktop: JWM git-905 
           Distro: Slacko Puppy Linux Linux 3.10.32 [ arch] 
Machine:   System: Hewlett-Packard (portable) product: Presario CQ57 Notebook PC v: 068C110003204910000620100
           Mobo: Hewlett-Packard model: 3577 v: 24.48
           Bios: Hewlett-Packard v: F.42 date: 11/07/2011
CPU:       Dual core AMD C-50 (-MCP-) cache: 1024 KB
           flags: (lm nx pae sse sse2 sse3 sse4a ssse3 svm) bmips: 3993 
           Clock Speeds: 1: 800 MHz 2: 800 MHz
Graphics:  Card: ATI Device 9804 bus-ID: 00:01.0
           Display Server: X.Org 1.12.4 drivers: ati,radeon (unloaded: vesa)
           Resolution: 1366x768@60.0hz
           GLX Renderer: Gallium 0.4 on AMD PALM
           GLX Version: 2.1 Mesa 8.0.4 Direct Rendering: Yes
Audio:     Card ATI SBx00 Azalia (Intel HDA) 
           driver: snd_hda_intel bus-ID: 00:14.2 
           Sound: Advanced Linux Sound Architecture v: k3.10.32
Network:   Card-1: Ralink Device 5390
           driver: rt2800pci v: 2.3.0 bus-ID: 07:00.0
           IF: wlan0 state: up speed: N/A duplex: N/A mac: <filter>
           Card-2: Realtek RTL8101E/RTL8102E PCI Express Fast Ethernet controller
           driver: r8169 v: 2.3LK-NAPI port: 2000 bus-ID: 06:00.0
           IF: eth0 state: down mac: <filter>
Drives:    HDD Total Size: NA (-)
           ID-1: /dev/sda model: WDC_WD2500BEVT size: 250.1GB
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 57.2C mobo: N/A gpu: 56.0 
           Fan Speeds (in rpm): cpu: N/A 
Info:      Processes: 91 Uptime: 5 min Memory: 99.7/1623.5MB 
           Init: SysVinit runlevel: 5 Gcc sys: 4.7.1 
           Client: Shell (sh) inxi: 2.1.28
Code:
$ inxi -Fxz
System:    Host: biker Kernel: 3.12-0.bpo.1-686-pae i686 (32 bit, gcc: 4.6.3)
           Desktop: Xfce 4.10.2 (Gtk 2.24.10) Distro: MX-14_13.99_386-xfce RC2 09 March 2014
Machine:   System: IBM product: 679421U
           Mobo: IBM model: IBM Bios: IBM version: 20KT46AUS date: 06/04/2004
CPU:       Single core Intel Pentium 4 CPU (-UP-) cache: 256 KB flags: (pae sse sse2) bmips: 3588.66 clocked at 1794.332 MHz
Graphics:  Card: NVIDIA NV6 [Vanta/Vanta LT] bus-ID: 01:00.0
           X.Org: 1.12.4 drivers: nouveau (unloaded: fbdev,vesa) Resolution: 1024x768@85.0hz
           GLX Renderer: Mesa DRI nv05 x86/MMX/SSE2 GLX Version: 1.2 Mesa 8.0.5 Direct Rendering: Yes
Audio:     Card: Intel 82801BA/BAM AC'97 Audio Controller driver: snd_intel8x0 ports: 1c00 1840 bus-ID: 00:1f.5
           Sound: Advanced Linux Sound Architecture ver: k3.12-0.bpo.1-686-pae
Network:   Card-1: Intel 82801BA/BAM/CA/CAM Ethernet Controller driver: e100 ver: 3.5.24-k2-NAPI port: 2000 bus-ID: 02:08.0
           IF: eth0 state: down mac: <filter>
           Card-2: Realtek RTL8187B Wireless 802.11g 54Mbps Network Adapter usb-ID: 001-002
           IF: N/A state: N/A mac: N/A
Drives:    HDD Total Size: 200.1GB (18.1% used) 1: id: /dev/sda model: ST3160215ACE size: 160.0GB
           2: id: /dev/sdb model: IC35L040AVVA07 size: 40.0GB
Partition: ID: / size: 11G used: 2.5G (26%) fs: ext4 ID: /home size: 27G used: 8.8G (35%) fs: ext4
           ID: swap-1 size: 1.17GB used: 0.00GB (0%) fs: swap
Sensors:   System Temperatures: cpu: 27.0C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 124 Uptime: 1:01 Memory: 252.9/1134.5MB Runlevel: 5
           Gcc sys: 4.7.2 Client: Shell (bash 4.2.37) inxi: 1.9.18
No need to make a script. It has already been done.

http://code.google.com/p/inxi/

Install instructions are on that page. It works on everything.
 
Old 05-13-2014, 07:21 PM   #12
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by rokytnji View Post
Inxi works with different versions of Linux

No need to make a script. It has already been done.
One of us is misunderstanding what the OP is trying to do.

As far as I can tell the OP has scripts that (s)he wants to run on different machines. The OP is under the impression that to run these scripts (s)he first needs to determine exactly what OS the script is on. I've tried to point out that trying to determine the OS is neither necessary nor very useful.

I think your interpretation of the OP post is that (s)he is trying to write a script that will determine what OS it is being run on.

OP: can you _please_ clarify what it is you are trying to achieve.

Evo2.
 
Old 05-13-2014, 07:32 PM   #13
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,349
Blog Entries: 28

Rep: Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147Reputation: 6147
cat /etc/*release* is a sort of a shotgun of a command loaded with wildcards instead of buckshot.

Most of the time, it hits a target. Sometimes not.
 
Old 05-13-2014, 07:40 PM   #14
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
[QUOTE]
Quote:
Originally Posted by evo2 View Post
Hi,

I think your interpretation of the OP post is that (s)he is trying to write a script that will determine what OS it is being run on.

OP: can you _please_ clarify what it is you are trying to achieve.
Yes, that is exactly what I would like to do.

For example this works on Puppy but not on other distros.
They probably use poweroff.

I also run one other distro.

Code:
#!/bin/bash
#     Linux Puppy 6.5.0
# This powers off Linux Puppy !
#

wmpoweroff

Last edited by Fixit7; 05-13-2014 at 07:41 PM.
 
Old 05-13-2014, 08:55 PM   #15
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by evo2 View Post
I think your interpretation of the OP post is that (s)he is trying to write a script that will determine what OS it is being run on.

OP: can you _please_ clarify what it is you are trying to achieve.
Quote:
Originally Posted by Fixit7 View Post
Yes, that is exactly what I would like to do.

For example this works on Puppy but not on other distros.
They probably use poweroff.
???? You just contradicted yourself.

If you want to know what command to use to shut down a machine, test what commands are available. If instead you try to test for what the OS is you'll need to populate and maintain a database of all possible OSs, and the corresponding commands for each OS.

Evo2.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which LXDE version of Linux has the newest version of Firefox and Open Office? coolguy2008 Linux - Newbie 6 09-19-2010 12:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration