Solved

Script to obtain hardware and OS information

Posted on 2003-12-03
7
283 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

929 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

9 Experts available now in Live!

Get 1:1 Help Now