Solved

Script to obtain hardware and OS information

Posted on 2003-12-03
7
284 Views
Last Modified: 2013-12-27
I’ve just been tasked to obtain the version of Solaris and the type of Sun workstation the user is using.  I know the uname –a command can give me the info I need.  What I don’t want to do is have to telnet to over 400 machines.  Is there a way, I can write a script which rsh’s to each machine by it’s IP address (5.212.144.xxx, 5.212.145.xxx) and write the output of each machine’s uname –a to a text file?  

Thanks,

Brian
0
Comment
Question by:bpb25
7 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 63 total points
ID: 9868916
You will have to set up the .rhosts file on each machine to do that ( or .ssh/authorized_keys if you use ssh).  So if you haven't already  done that, logging into each machine and running the uname command will be as quick.  If however you want to do it , so you can do it again later.
After you have set up your .rhosts file

x==0
while ( $x < 255)
do
rsh uname -a 5.212.144.$x >> /tmp/vers.txt
x=expr ($x + 1)
done

I'm not in front of a unix box at the moment, so my syntax may be a bit dodgy, try it and post the errors
0
 

Author Comment

by:bpb25
ID: 9868988
Ran the script, here's the error I got.

syntax error at line 7: 'x=expr' unexpected

Luckily the majority of the machines already have a .rhosts in place.

0
 
LVL 18

Expert Comment

by:liddler
ID: 9869182
x=`expr ($x+1)`
back single quotes, for a command substitution
0
 
LVL 7

Assisted Solution

by:glassd
glassd earned 62 total points
ID: 9869902
To make the math a bit easier, use Korn shell. Also the rsh line looks a bit odd. And only one subnet was tried. Try:

#!/bin/ksh
x==0
while ( $x < 255)
do
rsh 5.212.144.$x iuname -a >> /tmp/vers.txt
rsh 5.212.145.$x iuname -a >> /tmp/vers.txt
((x = x + 1))
done


0
 

Expert Comment

by:sagar24
ID: 9911451
Hi
You must have remote authentication database set
So create a file /.rhosts(assuming you  will remotely login as root)
enter your system name
create a script  and execute the script
#/bin/sh

x=1
for i in 144 145
do
while($x < 255)
do
rsh 5.212.$i.$x uname -a >> /tmp/info.txt
x=`expr $x + 1`
done
done

regards
sagar
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now