Well, DanS is a little more than misleading about the events that took
place. I'm the guy who challenged him to write the CMD script. I
certified with Microsoft more than a decade ago but since that time I
have not worked as a technical person. I also have about a year of Sun
Solaris experience, also from more than a decade ago. Think Solaris 2.5.
I discovered Linux not too long ago and started to post regarding my
progress on very basic things. Simple commands I'd learned, etc. And I
did this in a Linux group on Usenet. Mostly it's me being happy to make
progress on a platform that had been not previously discovered by me. So
this is all educational and adventurous at the same time.
The feedback to my n00b learning was helpful. So one day I write a bash
script that copies a DVD to my desktop and preps it for optical
manufacturing. That is to say, it copies the DVD and it removes certain
files that our clients often leave behind that they shouldn't. And this
is all done on a Mac because the Mac has the software which creates a
special type of pre-master for optical manufacturing. The Mac also has
bash and since I am learning bash it seemed a natural to do this as a
learning experience. And so I shared this with the group. What I was
doing, why and how I did it.
I mentioned that I thought Linux was pretty darn awesome and that the
script was really simple to do. A guy, such as me, with very little
experience was able to cobble together a workable script that worked out
quite nicely.
DanS here decided that mean Windows sucks. Which I never said, and have
since challenged him to find where I said such a thing. When DanS said
this could be done in CMD. I said, "Let's see it" because I believe
seeing is believing. I even went as far as to stipulate that my script
was hardly more than commands cobbled together, that I lacked experience
and that I simply wanted to see this to see if there were any weak spots
that became obvious when he duplicated the functions.
DanS likes to make this sound like I'm somehow vicious. Not at all. I
simply opined, and continue to opine, that I think bash is more elegant
and easy to read and learn than cmd. And that this is based on the
scripts he has shown me so far vs the ones I have been able to write
either on my own or with the help of others.
DanS has been nice enough to take the challenge and show me exactly what
the script would look like in cmd and it is most appreciated. Based on
what he has shown me I still hold the same opinion. DanS started the
discussion specifically with cmd, and so that is why the challenge is
regarding cmd.
He mentioned cmd yet again as myself and a small part of the group
started working on a new script that started out as me just looking for
random pieces of info about my Linux distribution. I'm sorry to say this
but if I make a positive comment about Linux DanS takes that as a
negative against Windows. I didn't even mention Windows at all when
making this script with the group. That discussion is started by DanS,
not I. I have absolutely no interest in Windows. I have years of using
it, supporting it, and I have moved on. That's not to say it is bad,
good or something else. Simply that my interests have moved on.
I don't mean or intend to invade your group or cause grief or start an
argument. Just posting my side of the event as he saw fit to mention it
here.
Thanks to those that helped DanS write the script. It has been very
educational for me and even interesting to see how such a thing could be
done in cmd.
That script in bash is currently this:
#!/bin/bash
#: Program Name : upcinfo
#: Usage : upcinfo
#: Objective : Gather Machine Info
#: Version : 3.4
#: Contributors : Bit Twister
#: Contributors : Chris Davies
#: Contributors : Jonathan N. Little
#: Contributors : Marek Novotny
# Setup
PATH=$PATH:/sbin:/usr/sbin
set -u
Version="3.4" # Removed tabs from output for better formatting control.
# Networking
_nic=""
_ip4=" "
_ip6=""
# Distribution Information
_wd1="" # word 1 of line
line="" # input line for processing
_substr="" # substring for word wraping
_rest="" # rest of the line
_tabs="" # tab characters for output
_long_line=""
_blank_col=" :"
_wrap_col=40
arr=()
Taint_Array=(
"A module with a non-GPL license has been loaded, this
includes modules with no license. Set by modutils >= 2.4.9 and
module-init-tools."
"A module was force loaded by insmod -f. Set by modutils >= 2.4.9
and module-init-tools."
"Unsafe SMP processors: SMP with CPUs not designed for SMP."
"A module was forcibly unloaded from the system by rmmod -f."
"A hardware machine check error occurred on the system."
"A bad page was discovered on the system."
"The user has asked that the system be marked 'tainted'.
This could be because they are running software that directly
modifies the hardware, or for other reasons."
"The system has died."
"The ACPI DSDT has been overridden with one supplied by
the user instead of using the one provided by the hardware."
"A kernel warning has occurred."
"A module from drivers/staging was loaded."
"The system is working around a severe firmware bug."
"An out-of-tree module has been loaded."
)
# Kernel Taint Status Description
function TaintDescribe ()
{ arr+=("$(echo -e "\n Taint Description:")")
TD=$(cat /proc/sys/kernel/tainted)
ix=0
for _mask in 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 ; do
(($TD & $_mask)) && arr+=("$(echo -e "\n${Taint_Array[$ix]}")")
((ix++))
done
arr+=(" ")
} # End Taint Description Function
# Test for text wrapping
function wrap_rest ()
{ _str_len=0 # substr length
_sub_str=""
_line_1=1
set -- $_rest
if [ $# -eq 0 ] ; then
echo " "
return
fi
while [ $# -gt 0 ] ; do
_len=${#1}
_str_len=$((_str_len + $_len))
if [ $_str_len -lt $_wrap_col ] ; then
_sub_str="$_sub_str $1"
else
if [ $_line_1 -eq 1 ] ; then
echo "$_col_1 $_sub_str"
_line_1=0
else
echo "$_blank_col $_sub_str"
fi
_str_len=0 ; _sub_str="$1"
fi
shift
done
if [ -n "$_sub_str" ] ; then
if [ $_line_1 -eq 1 ] ; then
echo "$_col_1 $_sub_str"
else
echo "$_blank_col $_sub_str"
fi
fi
} # end function wrap_rest
#*****************************
#* main code starts here
#*****************************
# Machine Info Header
arr+=("$(echo "User Name : $(whoami)")")
arr+=("$(echo "Date : $(date +%Y-%m-%d)")")
arr+=("$(echo "Machine Info : $Version")")
arr+=("$(echo -e "\n Brought to you by the folks at alt.os.linux.ubuntu")")
# Machine Information
arr+=("$(echo -e "\n Machine Information:")")
arr+=("$(echo "Hostname : $(uname -n)")")
arr+=("$(echo "Processor : $(uname -p)")")
arr+=("$(grep -m 1 'model name' /proc/cpuinfo | tr '\t' ' ')")
arr+=("$(grep -m 1 'cpu cores' /proc/cpuinfo | tr '\t' ' ')")
set -- $(cat /proc/meminfo | tr '\t' ' ')
arr+=("$(echo "Memory : $2 kB")")
arr+=("$(echo "Video Graphics : $(lspci | sed -n 's/^.*VGA[^:]*: *//p')")")
# test for blacklisting
if [ -f /etc/modprobe.d/nvidia-installer-disable-nouveau.conf ] ; then
arr+=("Nouveau : Blacklisted")
else
arr+=("Nouveau : Not blacklisted")
fi
DirectRender=$(glxinfo 2> /dev/null | grep -m 1 direct | awk '{print $3}')
arr+=("$(echo "Direct Render : $DirectRender")")
if [ ! -d /proc/asound ] ; then
arr+=("Sound : No sound support")
else
set -- $(grep -m 1 snd /proc/asound/modules)
arr+=("$(echo "Sound : $*")")
arr+=("$(echo "SoundDriver : $(cat /proc/asound/version | tr '\t' '
')")")
fi
arr+=("$(echo "OS : $(uname -o)")")
# Distribution Information
which lsb_release > /dev/null 2>&1
if [ $? -eq 0 ] ; then
arr+=("$(echo -e "\n lsb_release Description:")")
while read -r line; do
_ix=$(expr index "$line" ':')
_wd1="${line:0:$_ix-1}"
_rest=${line:$_ix}
set -- $(IFS=':' ; echo $_rest)
arr+=("$(echo "$_wd1 : $*")")
done < <(lsb_release -a | tr -d '*\t')
fi # end if [ -e $_fn ]
# Kernel Version
arr+=("$(echo -e "\n Kernel Status:")")
arr+=("$(echo "Kernel Version : $(uname -r)")")
# Kernel Taint Status and Description
Tainted=$(cat /proc/sys/kernel/tainted)
if [ $Tainted != "0" ] ; then
arr+=("$(echo "Taint Status : Tainted ($Tainted)")")
TaintDescribe
else
arr+=("$(echo "Taint Status : Not Tainted ($Tainted)")")
fi
# User Information
arr+=("$(echo -e "\n User Information:")")
arr+=("$(echo "User Name : $(whoami)")")
arr+=("$(echo "Home Dir : $HOME")")
arr+=("$(echo "Groups : $(groups)")")
# Networking, Hostname
arr+=("$(echo -e "\n Network Information:")")
arr+=("$(echo "Hostname : $(uname -n)")")
# Nameserver
arr+=("$(echo -e "\n Nameserver Information:")")
while read -r line; do
set -- $line
if [ $# -gt 1 ] ; then
_wd1=$1
shift
arr+=("$(echo "$_wd1 : $*")")
fi
done < <(grep -v ^# /etc/resolv.conf)
#*****************************************
#* let's dump the output array and wrap
#* any lines longer than $_wrap_col
#*****************************************
for i in ${!arr[*]} ; do
line="${arr[$i]}"
_ix=$(expr index "$line" ':')
if [ $_ix -eq 0 ] ; then # no formatting required
echo "$line"
else
_c=${line:$_ix:1}
if [ "$_c" != " " ] ; then # no formatting required
echo "$line"
else
_wd1="${line:0:$_ix-2}"
_col_1="$_wd1${_blank_col:$_ix-2}"
_rest="${line:$_ix}"
_len=${#_rest}
if [ $_len -gt $_wrap_col ] ; then
wrap_rest
else
echo "$_col_1 $_rest"
fi
fi
fi
done
# Storage
echo -e "\n Storage Information:"
df -H | sort -V
echo " "
--
Marek Novotny
A member of the Linux Foundation
http://www.linuxfoundation.org