Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What does Linux know about your hardware?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Wed Oct 15, 2008 2:13 am    Post subject: Reply with quote

Update 3: I managed to get Mandriva 2009 running and lo-and-behold, it has the lshw package as well Smile Ran the latest version (0.003 as per the link) w/o any problems. Good, even 1sf (troll) can use it now Razz Can somebody confirm that Fedora and Suse has the lshw package in their repo's as well? If that's the case it's safe to assume (IMO!) that the lshw package is generally available for Linux and the script doesn't need tweaking in that respect.

Suggestions and contributions are still welcome! (and properly credited if you put your real name in your message!)
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8455
Location: Warrington, UK

PostPosted: Wed Oct 15, 2008 9:23 am    Post subject: Reply with quote

lshw is pretty standard, but if you use something like the code in my first reply you're covered either way.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
AdamW



Joined: Thu Apr 17, 2008 12:45 am
Posts: 51

PostPosted: Thu Oct 23, 2008 4:48 am    Post subject: Reply with quote

Mandriva also provides lspcidrake , which will give you the Mandriva driver mappings, device description, and (with -v) the USB or PCI ID in a fairly concise and parseable form.
_________________
Adam Williamson
Mandriva
Community manager | Newsletter editor | Bugmaster | Proofreader | Translator | Packager
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Fri Oct 24, 2008 2:30 am    Post subject: Reply with quote

Hi Dutch_Master,

I've been playing around with your script Very Happy and realised I may have introduced a slight error with the code snippet I introduced. Sad Embarassed

The out put of the script is much more useful if it is continually appended to the "mysystem.txt" file. I missed a ">" with my code when setting the date/time the script was run. The full script should be:
Code:
#! /bin/bash
#
# script to collect hardware and software data on your system
# you'll need to be root to get proper results
# currently only works in Debian based systems, with the lshw package installed
# with contributions by Nelz and Ollie from the LXF forums

# when did you last run this script?
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt
# what kernel are you running?
echo "uname -a:" >> mysystem.txt
uname -a >> mysystem.txt
echo ========= >> mysystem.txt
# check if lshw is installed, then find out all you want from your hardware with lshw
if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!"
fi
echo ========= >> mysystem.txt
chmod 644 mysystem.txt
echo "done! read the file mysystem.txt in the current directory"
echo "use the cat and grep commands to select sections of interest if you're on the commandline"

exit 0


PS - I also recommend adding a version number to the comments at the top of the script Smile
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Fri Oct 24, 2008 3:42 am    Post subject: Reply with quote

Ah, I see your change. Well, it works w/o the extra > which really is only cosmetic, isn't it? Version inclusion makes sense: it's in. I'll add the extra > though Wink

Version 0.004 is available on the link in my original post on page 1 Smile

@AdamW: good to know, but that wasn't the intention of my script. This one is purely for gathering info on one's hardware as sometimes we get questions that require a bit more knowledge on the questionaire's hardware. I'm sure you, as a Mandriva dev, has experience with similar situations too, so feel free to use the script in Mandriva. Not yet decided on a licence, but it's free now and in the future. Hmm, given it relies on GPL software, there's an obvious choice here I guess? GPL then it is Smile
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8455
Location: Warrington, UK

PostPosted: Fri Oct 24, 2008 8:55 am    Post subject: Reply with quote

It's more than cosmetic, if you use > and the file already exists, it will be overwritten, unless you have the noclobber option set in your shell. In which case the script will bomb out with an error.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
AdamW



Joined: Thu Apr 17, 2008 12:45 am
Posts: 51

PostPosted: Fri Oct 24, 2008 8:59 pm    Post subject: Reply with quote

Dutch: yep, I was just adding it for information. Your script is neat, but I'm used to just using the output of lspcidrake -v. It provides everything I need to know for most issues - a vague idea of what the hardware actually is, its PCI / USB ID (always the most important thing, and the reason I hate lspci - neither lspci nor lspci -v lists the PCI ID by default, only lspci -n does...I mean, sheesh), and its default driver mapping. Of course, for a cross-distro effort, something generic like your script is needed.
_________________
Adam Williamson
Mandriva
Community manager | Newsletter editor | Bugmaster | Proofreader | Translator | Packager
Back to top
View user's profile Send private message
SMcE



Joined: Sun Jul 31, 2005 8:23 am
Posts: 10

PostPosted: Tue Jan 06, 2009 4:21 pm    Post subject: Reply with quote

Thanks Dutch_Master&friends for a very useful script. Now, if it just told me what version of Ubuntu I am using, it would be just perfect (at least I think it's Ubuntu, should never have changed that desktop wallpaper...)

A quick&dirty google gives me:
Quote:

$ cat /etc/issue
Ubuntu 8.04 \n \l

Which is pretty much what I needed to know, apart from the annoying formatting characters. lsb-release goes a bit futher for me:
Quote:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04"

(so it's Hardy!!) but funnily running lsb_release gives me:
Quote:

$ lsb_release -v
No LSB modules are available.

Can anybody improve on these??
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Sun Mar 08, 2009 5:46 am    Post subject: Reply with quote

I was starting to play around with getting more distro details as well SMcE and looked at "cat /etc/issue" and "cat /proc/version" instead of "uname -a" and "cat/lsb-release" provides more detail that is useful. So I have changed the script to:
Code:
#! /bin/bash
#
# script to collect hardware and software data on your system
# you'll need to be root to get proper results
# tested on Debian based systems, with the required lshw package
# installed and Mandriva 2009, who has the lshw package as well
# other distributions may work, if the lshw package is avalable and installed
# with contributions by Nelz and Ollie from the LXF forums
# see http://www.linuxformat.co.uk/index.php?name=PNphpBB2&file=viewtopic&t=8332
# this script is released under the GPL: http://www.gnu.org/copyleft/gpl.html
# current version: 0.005

# when did you last run this script?
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt
# what kernel are you running?
echo "Kernel details:" >> mysystem.txt
cat /proc/version >>mysystem.txt
echo "Distro LSB details:" >> mysystem.txt
cat /etc/lsb-release >> mysystem.txt
echo ========= >> mysystem.txt
# check if lshw is installed, then find out all you want from your hardware with lshw
if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!"
fi
echo ========= >> mysystem.txt
chmod 644 mysystem.txt
echo "Done! Read the file mysystem.txt in the current directory"
echo "Use the cat and grep commands to select sections of interest if you're on the commandline"
echo "Or open this file in a graphical editor like Kwrite or Gedit. Please, do not use Notepad!!"

exit 0


Do you think this is a useful update DM?
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8455
Location: Warrington, UK

PostPosted: Sun Mar 08, 2009 10:34 am    Post subject: Reply with quote

/etc/lsb-release isn't always there. Some distros install the LSB stuff as a separate, optional, package and for other distros it is just not relevant. To avoid the script aborting when the file isn't found, use

Code:
[[ -f /etc/lsb-release ]] && cat /etc/lsb-release >> mysystem.txt

_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Sat Oct 09, 2010 4:58 am    Post subject: Reply with quote

Admittedly "a tad" Rolling Eyes late, but version 0.006 as per Ollie and Nelz's suggestions can be found on the link in the original post on page 1. Unless some-one has a serious issue with it, it might be worth putting a Sticky on this thread for future (pun intended) visitors. (Mike, that's a hint Wink) And moving it to the Help section might improve its usage too Razz
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast