help needed in writing a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help needed in writing a script
# 1  
Old 10-03-2008
help needed in writing a script

when i run a command the output is something like this:

#3136 0.872914 01/17/08 22:06:36
#24817 1.231532 01/18/08 05:00:44
#15371 1.291679 01/18/08 03:00:08
#21279 2.130480 01/18/08 04:03:16
#7835 27.892056 01/18/08 00:01:32

i need to check if any one of the second column is greater than 5,if it greater than 5 then take the process id of that row(column1)
and i have to give this command: less <logfile> <processid>.

when i do this i get a screen filled with @.
then i again search for <processid> and i copy the text to word document

1)is there any command which gives the text of logfile directly instead of @ in the first go itself.
2)and do we have any command which copies the content returned by previous command in to a word document.


Thanks & Regards,
Cybersandex.
# 2  
Old 10-03-2008
Hammer & Screwdriver Perhaps this might get you started?

Code:
> cat file1
#3136 0.872914 01/17/08 22:06:36
#24817 1.231532 01/18/08 05:00:44
#15371 1.291679 01/18/08 03:00:08 
#21279 2.130480 01/18/08 04:03:16
#7835 27.892056 01/18/08 00:01:32

> echo "hello `awk '$2>5 {print $1}' file1 | tr -d "#"`"
hello 7835

Instead of doing an echo to say hello, other commands could be done. While you mention logfile, I could not understand what you meant or what this referred to.
# 3  
Old 10-03-2008
after i run this command:
cat sqllog_clrdg5q1 | grep SQL_ROUNDTRIP_TIME | cut -d' ' -f4,4,3,3,7,7,8,8 | sort -k 2,2n | tail -5

i get output like:
#3136 0.872914 01/17/08 22:06:36
#24817 1.231532 01/18/08 05:00:44
#15371 1.291679 01/18/08 03:00:08
#21279 2.130480 01/18/08 04:03:16
#7835 27.892056 01/18/08 00:01:32

now i have to copy the sqlquery which has run for more than 5 secs in to a word document
can we automate this whole process?
# 4  
Old 10-03-2008
Hammer & Screwdriver What is the rest of the info?

I can get to the 7835, but how do I know the sqlquery that you want to copy?

By the way, you might be able to streamline your original command.
original
Code:
>cat sqllog_clrdg5q1 | grep SQL_ROUNDTRIP_TIME | cut -d' ' -f4,4,3,3,7,7,8,8 | sort -k 2,2n | tail -5

proposed
Code:
>grep SQL_ROUNDTRIP_TIME sqllog_clrdg5q1 | cut -d' ' -f3,4,7,8 | sort -k 2,2n | tail -5

# 5  
Old 10-03-2008
we give: less sqllog_clrdg5q1 7835 and i get a screen wid @(astricks)
then i search wid 7835 like /#7835 and then i get output on the screen with the sql query.I copy this to a word document
# 6  
Old 10-03-2008
Perhaps I understand a little better now

Start by extracting a simplified log file of key data:

Code:
>grep SQL_ROUNDTRIP_TIME sqllog_clrdg5q1 | cut -d' ' -f3,4,7,8 | sort -k 2,2n | tail -5 > temp_sql

Then, to make your next step:

Code:
> echo `awk '$2>5 {print $1}' temp_sql | tr -d "#"`" > temp_sql2

So the file temp_sql2 will hold a listing of all the id #'s with more than 5 seconds.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Please help me writing this script

I work on a production server. I have to check one folder named "spool" and delete files under it , which are more than 5 minutes old. I do it manually by writing two commands. touch -t YYMMDDHHMMSS /tmp/timeinfo find /spool ! -newer /tmp/timeinfo -exec rm -rf {} \; I want to... (4 Replies)
Discussion started by: manalisharmabe
4 Replies

2. Shell Programming and Scripting

Help needed in writing a menu driven script

Hi, I was wondering if someone could help me write a shell script in Linux that backsup/restores data to anywhere I choose but it needs to be menu driven? Thanks, I'm new to Linux/Unix but liking it so far...just hoping to get to grips with the scripts! :) (7 Replies)
Discussion started by: Nicole
7 Replies

3. Shell Programming and Scripting

Help in writing script

i need some help in donig some actions on files in a library. i want to get the n last files, and print to the screen their name, date, and how many times a specific string appears in each file.. how can i do this..?... (6 Replies)
Discussion started by: eee
6 Replies

4. Shell Programming and Scripting

Please help me in writing my script

hello all, I have a script, used to search for the strings from the set of 5 similar pattern file from the log dir. So here it goes . The input parameter is a part of the file name. When during the script execution, the script should parse the input parameter to original file's with the same... (0 Replies)
Discussion started by: baraghun
0 Replies

5. Shell Programming and Scripting

Help me in writing the script

Hi, I have written a script which converts a give hexdecimal value to binary value in perl. But now, the problem is I should read every bit of it ( if its 10101010, i should read the value in each position and if the value in that position is 1 i should print a string and should exit if its... (1 Reply)
Discussion started by: prakashreddy
1 Replies

6. UNIX for Dummies Questions & Answers

Need help writing this script

Here is the script I am trying to write along with my answer I wrote. Please help me understand why it doesn't work. Create an executable script file called "newname" that will perform the followings: 1. Rename a file upon the user's request. If the file exists, prompt the user for... (1 Reply)
Discussion started by: wiggles
1 Replies

7. Shell Programming and Scripting

needed help in writing a script!

Hi all, I needed help in writing a script for the following question.please help. Non-recursive shell script that accepts any number of arguments and prints them in the Reverse order. (For example, if the script is named rargs, then executing rargs A B C should produce C B A on... (5 Replies)
Discussion started by: wrapster
5 Replies

8. Shell Programming and Scripting

Help needed for writing a script

I have a requirement to write a script to get the number of errors generated during a time period. How can I achieve this. To be exact, I need to get the number of 404 or 500 errors generated during a time period from 01 to 02 hrs from a webserver access log. Any help will be appreciated.... (4 Replies)
Discussion started by: sriram_1978
4 Replies

9. Shell Programming and Scripting

Help needed in writing awk script for xml source

Hi, i am not able to get an approach for converting xml file to flat file using awk programming. Can anyone help me out. The input xml is like this: <outer> <field1>one</field1> <field2>two</field2> <field3>three<Error Code=777 Description=12345/></field3> <field4>four</field4> </outer>... (2 Replies)
Discussion started by: naren_0101bits
2 Replies

10. Shell Programming and Scripting

need help writing a script

Hello everyone. Well, I will get right to the point. I am new to Perl and trying to learn it as much as I can. I have been assigned the task of writing a perl script to extract information from firewall logs. Like I said, I am new to Perl and I am having a tough time because I think what I am... (3 Replies)
Discussion started by: tarballed
3 Replies
Login or Register to Ask a Question