LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Puppy (https://www.linuxquestions.org/questions/puppy-71/)
-   -   Linux version (https://www.linuxquestions.org/questions/puppy-71/linux-version-4175504752/)

Fixit7 05-12-2014 03:02 PM

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

frankbell 05-12-2014 07:29 PM

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/"


Fixit7 05-12-2014 10:04 PM

cat /etc/*release*
gave this:

Quote:

cat: /etc/*release*: No such file or directory

273 05-13-2014 01:04 AM

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?

evo2 05-13-2014 01:19 AM

Hi,
Quote:

Originally Posted by Fixit7 (Post 5169529)
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.

Fixit7 05-13-2014 01:22 AM

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

evo2 05-13-2014 01:44 AM

Hi,
Quote:

Originally Posted by Fixit7 (Post 5169764)
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.

yancek 05-13-2014 11:16 AM

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.

Fixit7 05-13-2014 01:27 PM

# cat /etc/issue
Slacko Puppy Linux
Linux 3.10.5 [i686 arch]

evo2 05-13-2014 05:19 PM

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.

rokytnji 05-13-2014 06:40 PM

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.

evo2 05-13-2014 07:21 PM

Hi,
Quote:

Originally Posted by rokytnji (Post 5170317)
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.

frankbell 05-13-2014 07:32 PM

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.

Fixit7 05-13-2014 07:40 PM

[QUOTE]
Quote:

Originally Posted by evo2 (Post 5170331)
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


evo2 05-13-2014 08:55 PM

Hi,

Quote:

Originally Posted by evo2 (Post 5170331)
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 (Post 5170341)
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.


All times are GMT -5. The time now is 09:56 PM.