Need a help to automate a task


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a help to automate a task
# 1  
Old 11-29-2010
MySQL Need a help to automate a task

I need to automate a manual task using shell scripting. The scenario is like :-
Code:
#!/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 :-
Code:
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

Last edited by Scott; 11-29-2010 at 09:47 AM.. Reason: Code tags, please...
# 2  
Old 11-29-2010
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?
# 3  
Old 11-30-2010
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)
# 4  
Old 12-08-2010
Let me clarify my requirement

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 Smilie

Thanks,
Ren
# 5  
Old 12-08-2010
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:
Code:
(
echo '. ./.profile
<commands to generate more commands>
)|ssh user@rem_host ksh

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automate a task

Dear All, I am relatively new to UNIX and wanted to accomplish a simple task which should be automated. That's why I need your help. I shall briefly describe what I want. Basically, there is a process (X) (related to a particular software which I am using in my system) which automatically... (5 Replies)
Discussion started by: Samiran Dam
5 Replies

2. Shell Programming and Scripting

need help with an easy task

Hello everyone my name is Telis and i just registered in this forum.. i just started programming in linux shell and i need help with this easy task.. this is my code #!/bin/sh echo "What is your First name?" read name if ; then echo "Hello Master." else echo "Who are you?" fi when i... (2 Replies)
Discussion started by: Telis
2 Replies

3. Shell Programming and Scripting

Parallelize a task that have for

Dear all, I'm a newbie in programming and I would like to know if it is possible to parallelize the script: for l in {1..1000} do cut -f$l quase2 |tr "\n" "," |sed 's/$/\ /g' |sed '/^$/d' >a_$l.t done I tried: for l in {1..1000} do cut -f$l quase2 |tr "\n" "," |sed 's/$/\ /g' |sed... (7 Replies)
Discussion started by: valente
7 Replies

4. Shell Programming and Scripting

Task

Hi experts, I have a problem with the below shell task: I need to modify the file creatin a paired row , per each row which matches filter (e.g. number of nonempty columns = 5) Output should look like this: second row is original one from the input, first row(red) is pairing row, it's... (29 Replies)
Discussion started by: hernand
29 Replies

5. Shell Programming and Scripting

task

Hi all, I'm newbie and stuck here. Thanks for any help. Input(txt file) a b X c d Y e f Z g h W Requested output: a b X Y c d Y X e f Z W g h W Z Please use code tags when posting data and code samples! (10 Replies)
Discussion started by: hernand
10 Replies

6. UNIX for Advanced & Expert Users

Script that can Automate Printer adding task in HP-UX servers

I want to make a script to automate printer adding task.My inputs are like Printer name : xyz Port number :9001 I should write a script to make the Printer adding task will be automated. Like in manually adding task we are doing through hppi or jetadmin tools. ---------- Post updated at... (2 Replies)
Discussion started by: AnilKPatnaik
2 Replies

7. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

8. Shell Programming and Scripting

Need help with a manual task

I have an ASCII file that I receive on a monthly bases that is fixed length. I break the file into separate files based on a 5 character numerical sequence. I have 20 different sequences I have to find. the input file looks something like this xy-ins 2008yuthnrlsinrthsntwilgrha33260001... (4 Replies)
Discussion started by: jcalisi
4 Replies

9. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies

10. UNIX for Dummies Questions & Answers

process vs task

Hi, I am new to this forum and unix too. I have just started learning unix. As I was going through the first chapter, I read that unix is multitasking, multiprogramming, multiprocessing and multiuser OS. My question is: Is there any difference between a TASK and a PROCESS. How are PROCESS... (2 Replies)
Discussion started by: hana
2 Replies
Login or Register to Ask a Question