Connecting Tech Pros Worldwide Help | Site Map

i need a shell script

Newbie
 
Join Date: Jun 2007
Posts: 3
#1: Jun 22 '07
i need to make a script that queries relevant system information from the /proc file system, the uname command, the output of dmesg, and possibly other sources on the system. the script should collect this information in variables, format it, then store it in a text file.
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#2: Jun 22 '07

re: i need a shell script


Quote:

Originally Posted by thisissin

i need to make a script that queries relevant system information from the /proc file system, the uname command, the output of dmesg, and possibly other sources on the system. the script should collect this information in variables, format it, then store it in a text file.

Ok, so what do you have so far? Have you decided what shell you are using? Are you familiar with the different ways of getting that information?
Newbie
 
Join Date: Jun 2007
Posts: 3
#3: Jun 22 '07

re: i need a shell script


#!/bin/bash
#
#
#


name=$(uname -s)
version=$(uname -v)
hardware=$(uname -m)
release=$(uname -r)
mem=$(free -omt)
disk=$(df -lh)
hname=$(uname -n)
cpu=$(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/cpu MHz//')
cpumodel=$(cat /proc/cpuinfo | grep 'model name' | sed 's/model name//')
who=$(whoami)
lwho=$(logname)
uptime=$(uptime |sed 's/,.*$//')
#
#
echo "information about your PC"
echo "OS Type : $name"
echo "Hostname : $hname"
echo "Currently logged in as : $who"
echo "CPU Model $cpumodel"
echo "CPU Speed $cpu MHz"
echo "Kernel Version : $version"
echo "Kernel Release : $release"
echo "System Uptime :$uptime"
echo
echo "Hard Disk"
echo "$disk"
echo
echo "System Memory info"
echo "$mem"
echo
echo "/proc file system info"
procinfo=$(/usr/bin/procinfo)
echo "$procinfo"
echo
dmesg > /tmp/dmesg.out
cat /tmp/dmesg.out
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#4: Jun 22 '07

re: i need a shell script


Looks like you're doing pretty well on this, did you have a question?
Newbie
 
Join Date: Jun 2007
Posts: 3
#5: Jun 22 '07

re: i need a shell script


well at first when i read that scenario i was mindblow on where to start. but then looked at a couple sample scripts and went to town... all i need to do now is export all that information into a txt file.
sicarie's Avatar
Moderator
 
Join Date: Nov 2006
Location: USA
Posts: 3,929
#6: Jun 22 '07

re: i need a shell script


Quote:

Originally Posted by thisissin

well at first when i read that scenario i was mindblow on where to start. but then looked at a couple sample scripts and went to town... all i need to do now is export all that information into a txt file.

Oh cool, ok. Check this out. Looks like you can use the standard redirects in the script just as you would on the command line.
Reply