Approach to writting a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Approach to writting a script
# 1  
Old 02-03-2009
Approach to writting a script

Hello all,
I've just joined. I did a google search and your site came up,
I had a look and thought I'd like to become a member.

I'm from Ireland.

I've written a few scripts before, but this new task has me foxed.

I would like to figure out the best approach to achieving the following

A single script that does the following
login to machine a (I typically use putty to do this)
login to machine b (as above)
on machine_a run a command such as "service xxx stop; service xxx start"
on machine_a ps -ef | grep AppName to confirm the app started right
on machine_a run top, and grep for a process by name, and batch the cpu% usage result to a file ( I can do this already)

on machine_b cd to a specific directory
on machine_b run a script that points at machine_a

on machine_b, when the script finishes
machine_a will parse the result file, and confirm the average of the cpu% is less than a threshold

That's pretty much it.
The hard part I suppose would be the single script spawing scripts on two different machines and synchonising them?

Thanks for your help in advance! Smilie
Bloke
# 2  
Old 02-03-2009
The easiest approach from a scripting standpoint would be to use ssh to launch commands on the remote system. ssh user@host "command [options]"
# 3  
Old 02-04-2009
Thanks for reply.

When I tried that
ssh root@XXX.XXX.XXX.XXX "ls -al"

it asked me for a password.

As I would like to automate the process by scripting, without having to type in passwords.

Are there alternative approaches.
# 4  
Old 02-04-2009
Set up public key authentication for your account on the server. That should enable password-less login
# 5  
Old 02-04-2009
Setting up public key authentication looks quite complex, is there a less complex way?

I don't know how to do it.

Last edited by Bloke; 02-04-2009 at 06:30 PM..
# 6  
Old 02-04-2009
Or an alternative way to issue commands to two boxes from one script!
# 7  
Old 02-05-2009
Public key authentication is quite simple actually.
  1. $ ssh-keygen -b 2048 # This generates your key-pair
  2. SSH to the host, create a directory ~/.ssh with permissions 0700
  3. Paste the contents of (local) ~/.ssh/id_rsa.pub into (remote) ~/.ssh/authorized_keys
  4. Logout and try again to log in. If it doesn't ask for a password, you're all set
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What is the right approach to take?

Hello every one, I will love to know what is the best approach to take in obtaining books online. I find it disturbing just googling a book online and downloading it without actually paying for it. I strongly believe that this is wrong and that i may not be able to unlock the key contents and... (2 Replies)
Discussion started by: despiragado
2 Replies

2. Shell Programming and Scripting

Help with approach and developing script

Hi- I need to develop a script for following scenario in AIX and K shell environment.I am from windows server background for most my career ,so please bear with me and advise suitable approach and technical assistance.Having said that I am aware of unix shell commands but never pput together at... (1 Reply)
Discussion started by: nirasm
1 Replies

3. Red Hat

What would be the best approach?

I have a table in one of my DB. The DB is about 300 gig - of that 249 gig is in this table. The data is somewhat important but even if we delete half of it won't affect anybody. I would like to reclaim some space back so my question is what would be the best approach to accomplish this task.... (6 Replies)
Discussion started by: newborndba
6 Replies

4. Programming

Oracle Procedure approach

HI All , I am new to oracle procedures. Please help me for the approach to satify the requirement. I need to create procedures. with parameters passed ( say report,type,identities,country ) It should also call sql query within the procedures and passed parameters should be used in where clause... (2 Replies)
Discussion started by: Perlbaby
2 Replies

5. Shell Programming and Scripting

Need advice on approach for script

Greetings all. I have a repository server which receives, without exhaggeration, several million files a week. The majority of these files are in .csv format, which means they're highly compressable. They are spread throughout numerous directories where there are configured monitoring utilities... (4 Replies)
Discussion started by: msarro
4 Replies

6. SuSE

Write shell script using menu-driven approach to show various system

QUESTION: Write shell script using menu-driven approach to show various system configuration like 1) Currently logged user and his logname 2) Your current shell 3) Your home directory 4) Your current path setting 5) Your current working directory 6) Show Currently logged number of... (1 Reply)
Discussion started by: bboyjervis
1 Replies

7. Shell Programming and Scripting

writting a shell script to delete damage files

hi, I have 100 files say File1.mp3, File2.mp3 .......file100.mp3 i found that File1.mp3 to File50.mp3 are damaged. I want to delete the damaged files from the directory using sed with regex how can i do this. thanks (5 Replies)
Discussion started by: pchangba
5 Replies

8. Shell Programming and Scripting

Scp without writting

Hi, i have a file (filename xyz.file) and i scp it daily to server B. B runs a job daily and remove it. A sends it at 9am, B removes it at 915am. Now i have another server C, it also scp a file (xyz.file) to B. C will send to B at 930am and B will remove it at 10am. My worry is if B fails to... (7 Replies)
Discussion started by: new2ss
7 Replies

9. Shell Programming and Scripting

Writting to multiple file

Hi!, My script generates a lot of files while running.. The same output at any point may be diercted to some of them.. if I have 4 files file1 file2 file3 file4, echo "output" to file1 file2 file3 file4 Any ideas on how to do it?? (2 Replies)
Discussion started by: jyotipg
2 Replies
Login or Register to Ask a Question