[Techtalk] bash behaviour
Berenice
showercurtain2000 at yahoo.com
Fri Apr 4 23:23:04 EST 2003
I'm working on my first bash script, which is meant display cpu,
video,network and sound card information onscreen (incl. below). I
used 2 functions to do this (one for the cpu, and one for the cards).
At first it worked perfectly, but I had problems after I fiddled with
the if statements to try to improve it. I added other commands that
didn't work, and although I removed them, my function doesn't work
properly anymore. Now it repeats all the contents of /proc/pci 3
times. Can anyone explain why this happened?
Berenice
#!/bin/bash
cpu(){
echo $(grep -i "$1" /proc/cpuinfo);
}
echo "CPU:"
cpu name
cpu vendor
cpu mhz
echo
cardinfo(){
echo $(grep -i "$2" "$dir");
}
#problems started after I played with this
if test -f /proc/pci
then
dir="/proc/pci"
cardinfo ethernet
cardinfo vga
cardinfo audio
else
echo "PCI cards not found."
exit
fi
if test -f /proc/isapnp
then
dir="/proc/isapnp"
cardinfo ethernet
cardinfo vga
cardinfo audio
else
echo "ISAPNP cards not found."
exit
fi
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
More information about the Techtalk
mailing list