2010-01-08 23:31:18 Quick Dev Tools System Scan Script
Just a tiny shell script to give me a list of what's on a system and what the version is. This was just written for my needs, so probably doesn't include some things you'd also like. Please suggest anything that should be included, along with the line of code to nicely print out the information and I'll add it in.

The formatting of the output is perhaps just to my liking, but here's the source for you to adjust. (The "echo" mentions in the for-do loop is just there to give an easy way to creating padding between sections, making use of the fact that echo is probably on any unix system.)

Me, I have named this script, "lang" — but of course pick a better name if you must.

( sh )
  1  #!/bin/sh
2
echo
3
4 languages="gcc gfortran ghc java lua perl php python ruby gem fscript"
5 websystems="apachectl ant rails"
6 databases="mysql sqlite3"
7 versionsystems="cvs svn"
8 other="xcodebuild"
9
10 for language in $languages echo $websystems echo $databases echo $versionsystems $other
11 do
12
if [ `whereis $language` ]
13 then
14 case $language in
15
gcc ) gcc --version | grep gcc | awk '{ print "GCC",$3 }';;
16 gfortran ) gfortran --version | grep GCC | awk '{ print "GFortran",$4 }';;
17 ghc ) ghc --version | awk '{ split( $0, a, ", " ); print "Haskell (GHC)", a[2] }';;
18 java ) java -fullversion 2>&1 | sed 's/full version //' | sed 's/\"//g' | sed 's/java/Java/';;
19 lua ) lua -e 'print( _VERSION )';;
20 perl ) perl -version | grep 'is perl' | awk '{ print "Perl",$4 }';;
21 php ) php -v | grep PHP | grep built | awk '{print $1,$2}';;
22 python ) python -V;;
23 ruby ) ruby -v | awk '{ print "Ruby",$2 }';;
24 gem ) gem -v | awk '{ print "Ruby Gem",$1 }';;
25 fscript ) echo; echo "F-Script:"; fscript -v;;
26 apachectl ) apachectl -v | grep Apache | awk '{ print $3}' | sed 's/\// /';;
27 ant ) ant -version | awk '{ print $1,$2,$4 }';;
28 rails ) rails -v;;
29 mysql ) mysql --version | awk '{ print $1, $5 }';;
30 sqlite3 ) sqlite3 --version | awk '{ print "SQLite",$1 }';;
31 cvs ) cvs --version | grep client | sed 's/ (client\/server)//' | sed 's/ (CVS)//';;
32 svn ) svn --version | grep 'svn, version' | sed 's/, version//' | sed 's/svn/Subversion/';;
33 xcodebuild ) echo; xcodebuild -version | grep Xcode;;
34 echo ) echo;;
35 esac
36 fi
37
done
38 echo
Leave a comment