Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mystat.sh Script [SOLVED]
#1
Hello all...
I have a question about a script that I am working on... But a little background on me...

I have been using and building computers since the Dos 3 and Windows 1.0 days.
I have used Dos, Windows/NT, NT-Server (all flavors) and all OS/2 versions. Played with Linux on and off for years, just didn't stick with it.....
I even worked for a computer configuration company making hundreds of systems a day.
So I have some idea what is what...LOL
I have been on linux for two years thanks mostly do to Joe Collins and his videos.

With all that said, I have been poking around Joe's scripts and others, making some of them do what I like. Big Grin
Mind you,,,, I am no script writer or programer by any means but I know enough to make some changes by reading the "man pages" and Form's to see how the scripts work and I just "poke" at them to see what they do... Any way on to the question.... It is coming... Big Grin

I found some scripts on EzeeTalk  that were written by Richard Romig "sysinfo.sh, ipinfo.sh " which are some good stuff for sure about your system.
I used parts of them and made some of my own to get my script called "mystat.sh".
In Richard Romig script it pulls information about the motherboard, name and so on. the output looks like this:
Code:
Manufacturer: To be filled by O.E.M.
Product name: To be filled by O.E.M.
Version: To be filled by O.E.M.
Serial number: To be filled by O.E.M.
An here is a snippet of the code that is used to get this part of the information 
Code:
{
  echo 
  echo -e "File created: $today\n"
  echo -e "System information for $myhost:\n"
  echo "Manufacturer: $mfgname"
  echo "Product name: $prodname"
  echo "Version: $vername"
  echo -e "Serial number: $sernum\n"
Now for the QUESTION:
In all my years of building systems, I have never nor do I know how to add this information about the "Motherboard"... Does anyone know how this information is gathered ( I know the variable but where.) and where it comes from and how do you add said information about the mobo?

I assume it is in the Bios chip, but was wondering how it is DONE????

As a tech in the configuration company I never add this information to any system we built.
When it came to programing the computer, we installed a floppy disk and hooked them to the network and turned them on and let Norton do its thing...LOL We never booted it again... 
Sooooo....
Any information would be cool..... Thanks!
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#2
Try looking at the source of 'neofetch', which is a bash script that fetches certain information about your system. You can find it here.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#3
(06-16-2019, 08:20 PM)leon.p Wrote: Try looking at the source of 'neofetch', which is a bash script that fetches certain information about your system. You can find it here.

Thanks leop.p.... I have looked at that a little, but will look at it some more... Big Grin

What I really want to know is how the Motherboard information is applied to start with.
++++++++++++++++
Manufacturer: To be filled by O.E.M. <---
Product name: To be filled by O.E.M.<---
Version: To be filled by O.E.M.         <---
Serial number: To be filled by O.E.M.<---
++++++++++++++++
It says to be filled by O.E.M.---- How is that done and where?

Now in you run my script in VM Vbox, it has all the information for Vbox in the above O.E.M. area.

I know it is not a big deal, but it is a OCD thing...LOL

How does that get program and where does it go into...  Huh

Thanks for the reply!
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#4
dmidecode pulls information from the system's Desktiop Management Interface (DMI) or System Management BIOS (SMBIOS) table. I've never tried my script in a VM but it may be that it wouldn't exist in a VM. I think it would probably have to access the host machine's BIOS directly.

Another useful tool to use to get system information is inxi. It's in the default repositories for most Linux distros.
Reply
#5
(06-17-2019, 03:13 AM)rickromig Wrote: dmidecode pulls information from the system's Desktiop Management Interface (DMI) or System Management BIOS (SMBIOS) table. I've never tried my script in a VM but it may be that it wouldn't exist in a VM. I think it would probably have to access the host machine's BIOS directly.

Another useful tool to use to get system information is inxi. It's in the default repositories for most Linux distros.

Yep I know that the dmidecode pulls the info into the script, but the underlying question is from where? Lol
Yes it does work in a VM... That is where I first noticed that the information was filled in...

The below output is from my Manjaro VmBox..... It finds all the  Vbox stuff like the video driver too...Big Grin
Code:
System information for bruce-MjVbox:

Manufacturer: innotek GmbH
Product name: VirtualBox
Version: 1.2
Serial number: 0

Distro OS: Manjaro Linux
Codename: Illyria
Release: 18.0.4

CPU: AMD Phenom(tm) II X4 965 Processor
RAM: 3.8520 GB
Graphics Adapter: 
InnoTek Systemberatung GmbH VirtualBox Graphics Adapter

And here is the output from my Manjaro real steal Box...

Code:
System information for Reo-Manjaro:

==============
Manufacturer: MSI
Product name: MS-7151
Version: 1.0
Serial number: To Be Filled By O.E.M.

==============
Distro OS: Manjaro Linux
Codename: Illyria
Release: 18.0.4

==============
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
RAM: 1.9459 GB
Graphics Adapter: 
==============
Advanced Micro Devices, Inc. [AMD/ATI] Caicos [Radeon HD 6450/7450/8450 / R5 230 OEM]

As you can see, dmidecode finds this info from this old MSI board and is filled into the script...
So where is the information coming from... The Bios?

If that is the case how do I program it in there, or can I?
As this output states "Serial number: To Be Filled By O.E.M."... I want to be the O.E.M.... Lol

Yes I also have "inxi" running at the end of the script like this... and all the information is "Cat" to a file in my /home....
Code:
/usr/bin/inxi -c0 -Fxzd

Like I said not a script writer, but trying to understand why things work the way they do.
Sometimes I can read the "manpage" 30 times and don't know anymore than when I started....  Undecided

I'm going from being dangerous with this, to being totally explosive..... }Big Grin

I did look at the items that leon.p suggested and I did not see what I am looking for.. But did get some ideas for later...   Idea

To sum this up, I have a Dell tower and a laptop that the info is filled in. I have a Gigabyte and a Asus boards that are not filled in... Which I built... :-)
                     OCD is such a Great thing...

Also thanks for the reply rickromig....
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#6
Try doing a search for opensource bios and it will bring up a couple of bios projects that are opensource to look through, I think that with enough reading on it you will find the information you are looking for. (openbios, coreboot, libreboot)
Reply
#7
(06-17-2019, 08:16 PM)spudnuts Wrote: Try doing a search for opensource bios and it will bring up a couple of bios projects that are opensource to look through, I think that with enough reading on it you will find the information you are looking for. (openbios, coreboot, libreboot)

Well ok... I will give that a try...Big Grin
I guess it is a factory thing them.. Awell...  Sad

Thanks...
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#8
(06-16-2019, 09:24 PM)bescott9944 Wrote:
(06-16-2019, 08:20 PM)leon.p Wrote: Try looking at the source of 'neofetch', which is a bash script that fetches certain information about your system. You can find it here.

Thanks leop.p.... I have looked at that a little, but will look at it some more... Big Grin

What I really want to know is how the Motherboard information is applied to start with.
++++++++++++++++
Manufacturer: To be filled by O.E.M. <---
Product name: To be filled by O.E.M.<---
Version: To be filled by O.E.M.         <---
Serial number: To be filled by O.E.M.<---
++++++++++++++++
It says to be filled by O.E.M.---- How is that done and where?

Now in you run my script in VM Vbox, it has all the information for Vbox in the above O.E.M. area.

I know it is not a big deal, but it is a OCD thing...LOL

How does that get program and where does it go into...  Huh

Thanks for the reply!


The information is readily available in the /sys/class/dmi/id structure. 

Code:
$ cd /sys/class/dmi/id
$
$ ls -l
total 0
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_date
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_asset_tag
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_name
-r-------- 1 root root 4096 Jun 16 22:12 board_serial
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_asset_tag
-r-------- 1 root root 4096 Jun 16 22:12 chassis_serial
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_type
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 modalias
drwxr-xr-x 2 root root    0 Jun 16 22:12 power
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_family
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_name
-r-------- 1 root root 4096 Jun 16 22:12 product_serial
-r-------- 1 root root 4096 Jun 16 22:12 product_uuid
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_version
lrwxrwxrwx 1 root root    0 Jun 16 22:12 subsystem -> ../../../../class/dmi
-r--r--r-- 1 root root 4096 Jun 16 22:12 sys_vendor
-rw-r--r-- 1 root root 4096 Jun 16 22:12 uevent
$

Notice the board* items.  Simply cat them out.   The board_serial is root access only, but the other can be read by world.
Idea  Give a man a fish, and you feed him for a day. Teach a man to fish, and you feed him for a lifetime.

Reply
#9
(06-18-2019, 02:23 AM)deck_luck Wrote: The information is readily available in the /sys/class/dmi/id structure. 

Code:
$ cd /sys/class/dmi/id
$
$ ls -l
total 0
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_date
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 bios_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_asset_tag
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_name
-r-------- 1 root root 4096 Jun 16 22:12 board_serial
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 board_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_asset_tag
-r-------- 1 root root 4096 Jun 16 22:12 chassis_serial
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_type
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_vendor
-r--r--r-- 1 root root 4096 Jun 16 22:12 chassis_version
-r--r--r-- 1 root root 4096 Jun 16 22:12 modalias
drwxr-xr-x 2 root root    0 Jun 16 22:12 power
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_family
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_name
-r-------- 1 root root 4096 Jun 16 22:12 product_serial
-r-------- 1 root root 4096 Jun 16 22:12 product_uuid
-r--r--r-- 1 root root 4096 Jun 16 22:12 product_version
lrwxrwxrwx 1 root root    0 Jun 16 22:12 subsystem -> ../../../../class/dmi
-r--r--r-- 1 root root 4096 Jun 16 22:12 sys_vendor
-rw-r--r-- 1 root root 4096 Jun 16 22:12 uevent
$

Notice the board* items.  Simply cat them out.   The board_serial is root access only, but the other can be read by world.

Thanks for the reply...
I have looked at the files and found that the script was pulling the right/wrong information. I got that part fixed were the "System and Board" information is displayed....

I have 2 other issues that I am having fun with and have went down a rabbit hole so far that I lost sight of what I was doing to start with...  Confused 
I decided to take a brake for a day or two and regroup...Lol

What I am trying do do is pull the hard drive information from "lsblk" and pull what drives are mounted ie,

Code:
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0      2:0    1     4K  0 disk
sda      8:0    0 931.5G  0 disk
├─sda1   8:1    0   7.8G  0 part
├─sda2   8:2    0   4.9G  0 part /boot
├─sda3   8:3    0  48.8G  0 part /
└─sda4   8:4    0   870G  0 part /home
sr0     11:0    1  1024M  0 rom  
[bruce@Reo-Manjro ~]$

What I want to display is what hdd drives "sda" "sdb" and so on are on the system... 

I have manage to get "hdparm" to display the "sda" and "sdb" drives when both are there. When "sdb" is not there, I get a error to the console as STDOUT that "sdb" does not exist...
Code:
/dev/sdb: No such file or directory
/dev/sdb: No such file or directory
/dev/sdb: No such file or directory

Here is the code that I have got finding the drives...

Code:
# Hard drive
# Note: On some Distro's "hdpram" is not installed by default.
# You will have to install it for this section to function... -Bruce -6/18/19

hdmodel=$(sudo /sbin/hdparm -I /dev/sda | grep 'Model Number' | cut -c 22-)
hdserial=$(sudo /sbin/hdparm -I /dev/sda | grep 'Serial Number' | cut -c 22-)
hdsize=$(sudo /sbin/hdparm -I /dev/sda | grep 'GB' | cut -c 38-)
#
hdmodelb=$(sudo /sbin/hdparm -I /dev/sdb | grep 'Model Number' | cut -c 22- 2>/dev/null)
hdserialb=$(sudo /sbin/hdparm -I /dev/sdb | grep 'Serial Number' | cut -c 22- 2>/dev/null)
hdsizeb=$(sudo /sbin/hdparm -I /dev/sdb | grep 'GB' | cut -c 38- 2>/dev/null)

Here is some of the output section code that I have gotten to work so far.
Mind you that I have copied and pasted stuff that I have found and not much of this is my work, just editing it to work for me....

Code:
 fi
 echo -e "\nHard Disk information:"
 echo -e "\tModel Number : $hdmodel"
 echo -e "\tSerial Number: $hdserial"
 echo -e "\tCapacity: $hdsize\n"
 echo
  # if [ -a "$hdmodelb" ]; then
 echo -e "\tModel Number : $hdmodelb"
 echo -e "\tSerial Number: $hdserialb"
 echo -e "\tCapacity: $hdsizeb"

The thing is, I have several Linux box's that only have 1 drive and 2 that has 2 drives and I want to script to work on both and report what drives they have.
I know it can be done with "if" "read" "cat" or "else" "awk" or some damn thing but I can not get my head raped around it enough to sift out what I need to make it to work.
I know what I want, just can't get there. I have been reading "man's" and "--helps" for ever and I am more confused than ever now...Lol

Time to give it a rest for a bit like I said....
If you want the hole script I can post it.... 

Here is the output of the script so far...
Code:
<:> We May Need You Password bruce
<:> I am Checking.......
<:> Yes we need your password.. Please Enter It Now!.......
==============
/dev/sdb: No such file or directory
/dev/sdb: No such file or directory   <------- (The ERROR Issue)
/dev/sdb: No such file or directory



Mystat.sh, v.1.0.3 Copyright 2019, Bruce E. Scott
SysInfo, Copyright 2019, Richard Romig....
Current Version: v.1.0.3 Modified by Bruce Scott 6/18/19

File created: 22 June 2019 03:17:33

System information for Reo-Manjro:
###******************************###
Bios Manufacturer: American Megatrends Inc.
Bios Release Date: 10/18/2005
============
System Manufacturer: MSI
System Product Name: MS-7151
System Version: 1.0
System Serial Number: To Be Filled By O.E.M.\n
============
Board Manufacturer: MSI
Board Product Name: MS-7151
Board Version: 1.0
Board Serial Number: To be filled by O.E.M.\n
============
Distro OS: Manjaro Linux
Codename: Illyria
Release: 18.0.4

CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
RAM: 1.9459 GB
Graphics Adapter:
    Advanced Micro Devices, Inc. [AMD/ATI] Caicos [Radeon HD 6450/7450/8450 / R5 230 OEM]

Network Adapters:
    Ethernet: enp2s3 = Realtek Semiconductor Co., Ltd. RTL8169 PCI Gigabit Ethernet Controller (rev 10)
    MAC addr: 00:13:d:a:a:58

    IP Route Info:
default via 192.168.1.1 dev enp2s3 proto dhcp metric 100
192.168.1.0/24 dev enp2s3 proto kernel scope link src 192.168.1.106 metric 100


Hard Disk information:
    Model Number : MD1000GBDS                              
    Serial Number: MD18NMW1UZ10        
    Capacity:                        
1000204 MBytes (1000 GB)


    Model Number : <------- (When the drive is not there I just want to leave it blank)
    Serial Number:
    Capacity:

Partition information:
NAME     SIZE TYPE MOUNTPOINT
fd0        4K disk
sda    931.5G disk
├─sda1   7.8G part
├─sda2   4.9G part /boot
├─sda3  48.8G part /
└─sda4   870G part /home
sr0     1024M rom  

IP Information
==============
Public IP:
    216.252.50.202
Local IP:
    Ethernet: 192.168.1.106/24
Default Gateway:
    enp2s3    192.168.1.1
DNS Servers:
    192.168.1.1

Thanks for the help and the Quest Continues.....  Big Grin
Later!
**********************************************************
Taglines of the Day:
Today is the tomorrow you worried about yesterday.  Huh 

Everybody remember where we parked. - Kirk

To Boldly Go Where No BBS Has Gone Before. USS Stargazer BBS, Sheridan In.
Reply
#10
(06-22-2019, 07:56 AM)bescott9944 Wrote: What I am trying do do is pull the hard drive information from "lsblk" and pull what drives are mounted
[...]
What I want to display is what hdd drives "sda" "sdb" and so on are on the system... 
[...]
I have manage to get "hdparm" to display the "sda" and "sdb" drives when both are there.

'lsblk' is not easiely parsable. And using a non-standard tool
is also unnecessary. You can get information about everything
that is mounted simply with 'mount' or with 'df -aTh' or even
with 'cat /proc/self/mounts'. You will have to filter the output,
but that is rather easy.

To only see drives (physical and virtual) you can grep to filter
out the virtual file systems and show only the file systems which
are represented by a file in '/dev':

Code:
mount | grep '^/dev/'
df -aTh | grep '^/dev/'
grep '^/dev/' /proc/self/mounts
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)