Solved

Script to obtain hardware and OS information

Posted on 2003-12-03
7
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

717 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