New @ Scripting, Need Help ...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New @ Scripting, Need Help ...
# 1  
Old 05-01-2007
New @ Scripting, Need Help with If/Then & Line Breaks...

I hope this makes sense, but I need help with what is indicated with %%, below :

A.) ####List active servers and send to file####

# ps -ef | grep jboss | grep sh | awk '{if ($14) {print $12;}else {print $11}}' | sort > /export/home/kthatch/script_results

client302
client306
client309
client310
client312
client313
client314
client315
client317
client318
client319
client320
client321
client322
client323
client324
p001
p002
train310
train318
train319
train320


%% if results = p00*, then do B.) and delete p00* from the list above....%%

B.) ####List active tenants is a pod and append to file####

cd /u01/app/jboss/rnj/properties/%%p001%%/com/paisley/rnj/config
cat Application.properties | awk -F\. '/active=true/{print $1}' | sort >> /export/home/kthatch/script_results

cd /u01/app/jboss/rnj/properties/%%p002%%/com/paisley/rnj/config
cat Application.properties | awk -F.\ '/active=true/{print $1}' | sort >> /export/home/kthatch/script_results

%% p001 need to insert line break & header "P001" %%
client1000
client1001
client1002
client1003
client1004
client1005
client600
client601
client602
client603


%% p002 need to insert line break & header "P002" %%
train310
train318
train319
train320
client1021
client1022
client1023
client1024
client1025
client1026
client1027
client1028
client1029
client1030

Last edited by kthatch; 05-01-2007 at 07:31 PM.. Reason: Clarification
# 2  
Old 05-02-2007
I was hoping someone could help...

If anyone out there can help with this - it would be greatly appreciated... I am really struggling finding a solution. If you have questions or need clarification on anything, please ask...

Thanks in advance for any and all help!
# 3  
Old 05-02-2007
Quote:
Originally Posted by kthatch
If anyone out there can help with this - it would be greatly appreciated... I am really struggling finding a solution. If you have questions or need clarification on anything, please ask...

Thanks in advance for any and all help!
Please provide a sample of the input, a sample of the output, and a description of what needs to be done to get from one to the other.
# 4  
Old 05-03-2007
Ok - this is complicated - I need to create a script that looks for all of our active clients on a particular server. Most of our clients are single clients (clientXXX or trainXXX), but there are a few that we have set up in pods (p00X). There are up to 10 active clients in a pod. If possible, I would like the desired output to be numbered, as shown all the way at the bottom of this entry.

A.) ####List active clients and send to file####

INPUT >> # ps -ef | grep jboss | grep sh | awk '{if ($14) {print $12;}else {print $11}}' | sort > /export/home/kthatch/script_results

OUTPUT TO FILE 'script_results' >>

## this is the list of all active clients and pods ##
client302
client306
client309
client310
client312
client313
client314
client315
client317
client318
client319
client320
client321
client322
client323
client324
p001
p002
train310
train318
train319
train320


HOW DO I SCRIPT THIS >> if results from A.) = p00*, then do B.) and delete p00* from the list above.... if there is no p00* then DONE.

B.) ####List active tenants is a pod and append to file 'script_results'####

INPUT >> # cd /u01/app/jboss/rnj/properties/p001/com/paisley/rnj/config
cat Application.properties | awk -F\. '/active=true/{print $1}' | sort >> /export/home/kthatch/script_results


HOW DO I SCRIPT THIS >> when appending the clients in p001 I would like to insert line break & header

OUTPUT APPEND TO FILE 'script_results' >>

## this is the list of all active clients in pod P001 ##
client1000
client1001
client1002
client1003
client1004
client1005
client600
client601
client602
client603


INPUT >> # cd /u01/app/jboss/rnj/properties/p002/com/paisley/rnj/config
cat Application.properties | awk -F.\ '/active=true/{print $1}' | sort >> /export/home/kthatch/script_results


OUTPUT APPEND TO FILE 'script_results' >>

HOW DO I SCRIPT THIS >> when appending the clients in p002 I would like to insert line break & header

## this is the list of all active clients in pod P002 ##
train310
train318
train319
train320
client1021
client1022
client1023
client1024
client1025
client1026
client1027
client1028
client1029
client1030


DESIRED OUTPUT:

## this is the list of all active clients and pods ##
1. client302
2. client306
3. client309
4. client310
5. client312
6. client313
7. client314
8. client315
9. client317
10. client318
11. client319
12. client320
13. client321
14. client322
15. client323
16. client324
17. train310
18. train318
19. train319
20. train320

## this is the list of all active clients in pod P001 ##
21. client1000
22. client1001
23. client1002
24. client1003
25. client1004
26. client1005
27. client600
28. client601
29. client602
30. client603

## this is the list of all active clients in pod P002 ##
31. train310
32. train318
33. train319
34. train320
35. client1021
36. client1022
37. client1023
38. client1024
39. client1025
40. client1026
41. client1027
42. client1028
43. client1029
44. client1030
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

2. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

3. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

4. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. UNIX for Dummies Questions & Answers

Scripting Help

Hello all. Like Ive stated before, I am new to world of Unix. I was given the tast to create a script that will concatenate 20 files into one file. I know that the cat command is to be used but I am looking for something to get started on. Again, basically I need to wrtie a script that whill... (3 Replies)
Discussion started by: ndoggy020
3 Replies

7. UNIX for Advanced & Expert Users

Need help on scripting

in unix bc command is used as calculator and also for conversion, i want to convert 5f to decimal. but bc dont consider 5f as hex value it considers 5F as hex value. I get 5f from other iteration so i cant change that f to F...is there any way to convert 5f to decimal ot 5f to 5F :rolleyes: (2 Replies)
Discussion started by: abhinandantn
2 Replies

8. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

9. Shell Programming and Scripting

scripting guru's pls help me with scripting on AIX

can someone pls help me with the script for a files coming from one system to a particular directory and i want to write a script to move those files to another directory on different system by renaming the files... pls someone help me on this... thanking in anticipation.... (1 Reply)
Discussion started by: thatiprashant
1 Replies

10. AIX

New to scripting

We have a scripting requirement, Background: On a particular path, we compress a load of log files into tar.gz. This is done on an hourly basis throughout the day and it produces files of the following format, 2005-08-05-00-021031.tar.gz as an example. This is done by a script. We need: ... (2 Replies)
Discussion started by: rajesh_149
2 Replies
Login or Register to Ask a Question