experimental system info gathering script
#!/bin/sh
# script exercise
#
# 1) hostname (hint: hostname or uname)
# 2) IP Address (hint: ifconfig)
# 3) subnet mask (hint: ifconfig/grep/awk)
# 4) list passwd (hint: cat)
# 5) version of the OS (hint: uname)
#
# add line between each entry "-------------------------------------------"
# OUTPUT FILE called: /tmp/sysinfo.txt
#
# author: john date: Apr 2, 2004
########################################################################
# define variables - change command paths as needed for OS version
FILE=/tmp/sysinfo.txt
HOST=/bin/hostname
IFCFG=/sbin/ifconfig
GREP=/bin/grep
AWK=/bin/awk
SED=/bin/sed
CAT=/bin/cat
UNAME="/bin/uname -a"
########################################################################
# begin script
$CAT /dev/null > $FILE
# 1 hostname
echo "hostname" >> $FILE
$HOST >> $FILE
echo "-------------------------------------------" >> $FILE
# 2 ip address
echo "ip address" >> $FILE
$IFCFG | $GREP inet | $GREP -v 127 | $AWK '{print $2}' | $SED 's/addr:/ /g' >> $FILE
echo "-------------------------------------------" >> $FILE
# 3 subnet mask
echo "subnet mask" >> $FILE
$IFCFG | $GREP Mask | $AWK '{print $4}' | $SED 's/Mask:/ /g' >> $FILE
echo "-------------------------------------------" >> $FILE
# 4 passwd
echo "/etc/passwd" >> $FILE
$CAT /etc/passwd >> $FILE
echo "-------------------------------------------" >> $FILE
# 5 OS version
echo "OS version" >> $FILE
# command line: uname -a | awk '{print $3}'
$UNAME | $AWK '{print $3}' >> $FILE
echo "-------------------------------------------" >> $FILE
|
The Art of Linux System Administration published by O'Reilly Media Study Guide for the LPIC-2 Certification Exams |
![]() Wagoneers FULL SIZE JEEPS JeepMeister "Jeep is America's -Enzo Ferrari MeisterTech Diesels + |
One Page Overview of Linux Commands click for an image of the 5 essential Linux commands An Intro to Linux |
at Midway Auto on SR9 in Snohomish, or at Northland Diesel in Bellingham, WA |