Tuesday, May 27, 2008

Check OS Script ...

I had to check all hosts in a list , if its windows or unix.

Here's what helps identify whether it is Unix or Windows,
Note: Our Windows systems did not have ssh daemon running,


bash-2.03$ cat checkos.sh
#!/bin/sh
for host in `cat list_of_host`
do
if version=`(sleep 1 ; echo "") | telnet $host 22 | grep -i SSH`
then
echo "$host $version" >> HOSt-SSH-Running
else
echo "$host" >> HOST-SSH-Not-running
fi
done


The above scripts verify if the list of host in file has ssh daemon
running on port 22, in case if it finds running then it appends
that host to HOSt-SSH-Running and rest in HOST-SSH-Not-running.