Need a help to automate a task

I need to automate a manual task using shell scripting. The scenario is like :-

#!/usr/bin/sh
echo "please enter the name of the lab server to test ..."
read s
ssh $s

This is peace of the script which will allow me to login to another server using "ssh". I have a conf file which is having entries like :-

best1,ls /opt/bmc/Patrol3/*/best1

In this, 1st one is the name of a product and 2nd one is the way to check the product version. All i have to do is to login to some servers(that part i have aleady done) and check the product version and write it into another file with product name and version and kept it in the server itself using the conf file mentioned above.

Thanks in advance,
ren

It would be better to make a web page, where the server names are submit buttons. Products might then be radio buttons or a second, subsequent page of submit buttons.

Do all servers have all products, and the same dir structure as the config file, or is there a separate config file on each server?

Renjesh,

You have mentioned that login part you have taken care already.I believe its via passwordless login.

Put the list of servernames in a file then execute the following

USER=<name>
for SERV in `cat servernames`
do
ssh $USER@$SERV best1,ls /opt/bmc/Patrol3/*/best1 > somefile
done

This could be simple one but if you don't ve password less login setup you need to type the password for every server manually otherwise go for a perl CPAN module (Net::SSH)

I think i confused everyone. Let me clear you my reqyirements :-

Leave login part that is already taking care.

I have conf file in each file which has two entries seperated by comma. look like :-
best1,ls /opt/bmc/Patrol3/*/best1
......, .......................

In which "Best1" is the product name and "ls /opt/bmc/Patrol3/*/best1" is the way to find the product version of Best1 in that particular server.

Now what i need is to run the second part(ls /opt/bmc/Patrol3/*/best1) in the server and forward output with corresponding product name to a file. The output file should look like

Product name Version
Best1 3.0.1
Loganame 1.0
..... ...
.... ...

Note :- The file is varying for each server(contain lot of product) as the product in each server is different.

I hope i am not confusing again :slight_smile:

Thanks,
Ren

When doing more complex remote things, often you need to dot an environment script on the remote end so that shell is as capable as a login. A .profile that segregates all tty related stuff at the end in an if is the best way to do this.

If you don't want to distribute a remote script to each, something like this is easily tested and predictable for big command sets:

(
echo '. ./.profile
<commands to generate more commands>
)|ssh user@rem_host ksh