formating output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting formating output
# 8  
Old 02-01-2007
Code:
awk '/idle/{sub(/s.*/,"",$2);if(($3~/^&/)||(($2+0)>20000))print "kill -9",$4}' \
FS="idle |s</td><td>|/logs/imanscript" RS=".syslog" file

# 9  
Old 02-01-2007
Thanks for the commands. Could you please explain the above command.

Thank You.
# 10  
Old 02-01-2007
As it is quite trivial,
could please tell me which part is not clear?
# 11  
Old 02-01-2007
The above command not working.

=> awk '/idle/{sub(/s.*/,"",$2);if(($3~/^&/)||(($2+0)>20000))print "kill -9",$4}' \FS="idle |s</td><td>|/logs/imanscript"RS=
".syslog" proc.txt
kill -9 4628
infodba-marabou:/tmp

here is my list

=> awk '/idle/{sub(/s.*/,"",$2);print "Idle is:",$2,"PID is:",$3}' FS="idle |/logs/imanscript" RS=".syslog" proc.txt
Idle is: 4639 PID is: 3568
Idle is: 4628 PID is: 896
Idle is: 4276 PID is: 29204
Idle is: 10535 PID is: 9994
Idle is: 8982 PID is: 7599
Idle is: 13046 PID is: 1963
Idle is: 20419 PID is: 16225
Idle is: 630 PID is: 10210
Idle is: 25666 PID is: 561
Idle is: 30690 PID is: 16278
Idle is: 24137 PID is: 15120
Idle is: 32917 PID is: 25488
# 12  
Old 02-01-2007
Quote:
Originally Posted by radoulov
Code:
awk '/idle/{sub(/s.*/,"",$2);if(($3~/^&/)||(($2+0)>20000))print "kill -9",$4}' \
FS="idle |s</td><td>|/logs/imanscript" RS=".syslog" file

Smilie My AIX version of awk (not GNU) support only one character for RS variable : RS=".syslog" is treated as RS="."


Jean-Pierre.
# 13  
Old 02-01-2007
Please explain me the below command

please explain the whole.. Thanks.

(awk '/idle/{sub(/s.*/,"",$2);if(($2+0)>20000)print "kill -9",$3}' \
FS="idle |/logs/imanscript" RS=".syslog" file)

and also please help me to find the unreferenced process ie; Process with no users owning.

thanks.

Last edited by Krrishv; 02-01-2007 at 08:50 AM..
# 14  
Old 02-01-2007
Quote:
Originally Posted by Krrishv
The above command not working.

=> awk '/idle/{sub(/s.*/,"",$2);if(($3~/^&/)||(($2+0)>20000))print "kill -9",$4}' \FS="idle |s</td><td>|/logs/imanscript"RS=
".syslog" proc.txt
kill -9 4628
infodba-marabou:/tmp
May be it's because of the html formating (with copy/paste from the forum ...).

On HP-UX:

Code:
$ cat file
Content-type: text/html

<H2>No query</H2>
infodba-marabou:/tmp
=> export QUERY_STRING="IMAN_server_report=full"
infodba-marabou:/tmp
=> $IMAN_ROOT/web/htdocs/cgi-bin/iman > /tmp/proc.txt
infodba-marabou:/tmp
=> cat proc.txt
Content-type: text/html

<HTML><META HTTP-EQUIV="REFRESH" CONTENT=10><HEAD><TITLE>TcEng Web server report</TITLE>
</HEAD><BODY>
<H1>TcEng Web server report</H1>
<p>Thu Feb 1 00:16:43 2007 - I am alive and well (pid 712), up since Sat Dec 16 22:26:32 2006</p>
<p>click <a href=/iman>here</a> to login to this server</p>
<p>click <a href="/cgi-bin/iman?IMAN_server_report">here</a> for a shortened report</p><p>click <a href="/cgi-bin/iman?IMAN_server_report=xml">here</a> for an xml report</p><p>Completed 47155 out of 47183 queries; averag
e runtime 2.252 secs (4 timeouts).</p>

<hr>
<H2>Preferences</H2><pre>
Port number: 8181
Select time: 18000
Heartbeat time: 1000
Query time limit: 18000
Maximum number of queries: 750
Minimum number of free processes: 1
Maximum number of processes: 500
Soft login timeout: 120
Hard login timeout: 36000
Process lifespan (in queries): 10000
Maximum login processes per user: 1
Maximum retries on blocked sockets (Windows only): 5
Maximum concurrent logins 500
Maximum CPU usage 80
CPU usage monitoring 0
CPU usage check interval 10
Maximum no of requests/user in queue 5
Maximum length of the queue of pending connections 128
Number of active file descriptors: 1760
Monitoring switch: 1
Internal buffer size: 16384
IMANScript program: /Application/ugs/tceng/tceng0912/web/bin/imanscript
IMAN Document Root: /Application/ugs/tceng/tceng0912/web/htdocs
IMAN Environment:

</pre>
<hr>
<H2>Processes</H2><table align=center width=100% border=1><tr><th>No.</th><th>State</th><th>Query</th><th>Time s</th><th>User</th><th>Processed</th><th>Syslog</th></tr><tr><td>1</td><td>ready</td><td>&nbsp;</td><td>idle 46s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript9994.syslog</td></tr><tr><td>2</td><td>ready</td><td>&nbsp;</td><td>idle 937s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript7599.syslog</td></tr><tr><td>3</td><td>ready</td><td>&nbsp;</td><td>idle 469s</td><td>X036091&nbsp;</td><td>24</td><td>/Application/ugsvols/bldata01/logs/imanscript1963.syslog</td></tr><tr><td>4</td><td>ready</td><td>&nbsp;</td><td>idle 7842s</td><td>X045672&nbsp;</td><td>7</td><td>/Application/ugsvols/bldata01/logs/imanscript16225.syslog</td></tr><tr><td>5</td><td>ready</td><td>&nbsp;</td><td>idle 9989s</td><td>X035077 &nbsp;</td><td>5</td><td>/Application/ugsvols/bldata01/logs/imanscript10210.syslog</td></tr><tr><td>6</td><td>ready</td><td>&nbsp;</td><td>idle 13089s</td><td>X035466&nbsp;</td><td>5</td><td>/Application/ugsvols/bldata01/logs/imanscript561.syslog</td></tr><tr><td>7</td><td>ready</td><td>&nbsp;</td><td>idle 18113s</td><td>103818&nbsp;</td><td>5</td><td>/Application/ugsvols/bldata01/logs/imanscript16278.syslog</td></tr><tr><td>8</td><td>ready</td><td>&nbsp;</td><td>idle 11560s</td><td>X039371&nbsp;</td><td>15</td><td>/Application/ugsvols/bldata01/logs/imanscript15120.syslog</td></tr><tr><td>9</td><td>ready</td><td>&nbsp;</td><td>idle 20340s</td><td>22320&nbsp;</td><td>4</td><td>/Application/ugsvols/bldata01/logs/imanscript25488.syslog</td></tr><tr><td>10</td><td>ready</td><td>&nbsp;</td><td>idle 27042s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript20999.syslog</td></tr><tr><td>11</td><td>ready</td><td>&nbsp;</td><td>idle 27504s</td><td>101568&nbsp;</td><td>13</td><td>/Application/ugsvols/bldata01/logs/imanscript19396.syslog</td></tr><tr><td>12</td><td>ready</td><td>&nbsp;</td><td>idle 29098s</td><td>64920&nbsp;</td><td>10</td><td>/Application/ugsvols/bldata01/logs/imanscript14646.syslog</td></tr><tr><td>13</td><td>ready</td><td>&nbsp;</td><td>idle 30198s</td><td>X030111 &nbsp;</td><td>3</td><td>/Application/ugsvols/bldata01/logs/imanscript7582.syslog</td></tr><tr><td>14</td><td>ready</td><td>&nbsp;</td><td>idle 31676s</td><td>X041708&nbsp;</td><td>42</td><td>/Application/ugsvols/bldata01/logs/imanscript7183.syslog</td></tr><tr><td>15</td><td>ready</td><td>&nbsp;</td><td>idle 34199s</td><td>67733&nbsp;</td><td>40</td><td>/Application/ugsvols/bldata01/logs/imanscript18706.syslog</td></tr><tr><td>16</td><td>ready</td><td>&nbsp;</td><td>idle 31602s</td><td>79826&nbsp;</td><td>14</td><td>/Application/ugsvols/bldata01/logs/imanscript22502.syslog</td></tr><tr><td>17</td><td>ready</td><td>&nbsp;</td><td>idle 51645s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript12580.syslog</td></tr><tr><td>18</td><td>ready</td><td>&nbsp;</td><td>idle 30371s</td><td>11421&nbsp;</td><td>34</td><td>/Application/ugsvols/bldata01/logs/imanscript29761.syslog</td></tr><tr><td>19</td><td>ready</td><td>&nbsp;</td><td>idle 56147s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript29658.syslog</td></tr><tr><td>20</td><td>ready</td><td>&nbsp;</td><td>idle 30908s</td><td>X035887&nbsp;</td><td>74</td><td>/Application/ugsvols/bldata01/logs/imanscript20039.syslog</td></tr><tr><td>21</td><td>ready</td><td>&nbsp;</td><td>idle 31650s</td><td>X042268&nbsp;</td><td>95</td><td>/Application/ugsvols/bldata01/logs/imanscript14166.syslog</td></tr><tr><td>22</td><td>ready</td><td>&nbsp;</td><td>idle 34610s</td><td>X044587&nbsp;</td><td>242</td><td>/Application/ugsvols/bldata01/logs/imanscript929.syslog</td></tr><tr><td>23</td><td>ready</td><td>&nbsp;</td><td>idle 80449s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript18783.syslog</td></tr><tr><td>24</td><td>ready</td><td>&nbsp;</td><td>idle 84051s</td><td>&nbsp;</td><td>1</td><td>/Application/ugsvols/bldata01/logs/imanscript5679.syslog</td></tr></table>
<hr>
<H2>Queries</H2><p>No queries.</p>

<hr>
<h2>Recently deceased processes</h2><table border=1><tr><th>username</th><th>syslog</th></tr>
<tr><td>90927&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript28329.syslog</td></tr>
<tr><td>11920&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript12775.syslog</td></tr>
<tr><td>83144&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript16492.syslog</td></tr>
<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23739.syslog</td></tr>
<tr><td>11403&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript10134.syslog</td></tr>
<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23248.syslog</td></tr>
<tr><td>&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript23153.syslog</td></tr>
<tr><td>X033586&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript1533.syslog</td></tr>
<tr><td>X037095&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript5629.syslog</td></tr>
<tr><td>91011&nbsp;</td><td>/Application/ugsvols/bldata01/logs/imanscript9653.syslog</td></tr>
</table>

$ type awk
awk is /usr/bin/awk
$ what /usr/bin/awk
/usr/bin/awk:
         main.c $Date: 2004/12/05 21:30:07 $Revision: r11.11/2 PATCH_11.11 (PHCO_29952)
         tran.c $Date: 2004/12/05 21:30:07 $Revision: r11.11/3 PATCH_11.11 (PHCO_29952)
         lib.c $Date: 2002/09/03 22:10:33 $Revision: r11.11/1 PATCH_11.11 (PHCO_27559)
         run.c $Date: 2004/12/05 21:30:07 $Revision: r11.11/4 PATCH_11.11 (PHCO_29952)
         $Revision: @(#) awk  R11.11_BL2004_1205_4 PATCH_11.11 PHCO_29952 

$ awk '/idle/{sub(/s.*/,"",$2);sub(/<\/td>.*/,"",$3); proc=$3; \
> if(($3~/^&/)||(($2+0)>20000))print "Idle is:",$2, "Process is:", proc , "PID is:", $4}' \
> FS="idle |s</td><td>|/logs/imanscript" RS=".syslog" file
Idle is: 46 Process is: &nbsp; PID is: 9994
Idle is: 937 Process is: &nbsp; PID is: 7599
Idle is: 20340 Process is: 22320&nbsp; PID is: 25488
Idle is: 27042 Process is: &nbsp; PID is: 20999
Idle is: 27504 Process is: 101568&nbsp; PID is: 19396
Idle is: 29098 Process is: 64920&nbsp; PID is: 14646
Idle is: 30198 Process is: X030111 &nbsp; PID is: 7582
Idle is: 31676 Process is: X041708&nbsp; PID is: 7183
Idle is: 34199 Process is: 67733&nbsp; PID is: 18706
Idle is: 31602 Process is: 79826&nbsp; PID is: 22502
Idle is: 51645 Process is: &nbsp; PID is: 12580
Idle is: 30371 Process is: 11421&nbsp; PID is: 29761
Idle is: 56147 Process is: &nbsp; PID is: 29658
Idle is: 30908 Process is: X035887&nbsp; PID is: 20039
Idle is: 31650 Process is: X042268&nbsp; PID is: 14166
Idle is: 34610 Process is: X044587&nbsp; PID is: 929
Idle is: 80449 Process is: &nbsp; PID is: 18783
Idle is: 84051 Process is: &nbsp; PID is: 5679

For me the process table is in one line!

Anway,
if you understand the concepts (FS and RS),
you'll be able to adjust it for your needs.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

2. UNIX for Dummies Questions & Answers

Help with formating when using mailx

Hi I am a newbie here. I tried searching for the solution but I guess I either didn't find it or there hasn't been one posted. my problem is I spooled the results of a query into a .txt file. When I cat the file the formating looks great. All the columns are aligned. However once I mailx the... (2 Replies)
Discussion started by: RB26DETT
2 Replies

3. UNIX for Advanced & Expert Users

remove print formating from printer output file

I have a print file taken from the print spooler and I want to delete all the formatting leaving only the text. If you vi the file it shows "\304\304 ...." which translates into a printed line on print output. I need to be able to edit and pass this file to another process Thnaks (10 Replies)
Discussion started by: petercp
10 Replies

4. UNIX for Advanced & Expert Users

Formating and Parsing Autosys output

if you want to parse the output from an autosys you can use the below autorep -j Prefix_% | awk '{ if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$5 ; else if ($6 ~ /^/) printf "%-20s \t\t %-20s\n",$1,$6; else printf "%-20s \t\t %-20s\n",$1,$4 }' | awk '{ if ($2... (1 Reply)
Discussion started by: phpsnook
1 Replies

5. Shell Programming and Scripting

Formating output

Hello Team i have a file with following data (as columns). I need implement a syntax like below for altering table ALTER TABLE1 TABLENAME ADD COLUMN COL1 CHAR(5) NOT NULL WITH DEFAULT ADD COLUMN COL2 CHAR(5) .. .. ADD COLUMN COLn CHAR(5) NOT NULL... (1 Reply)
Discussion started by: rocking77
1 Replies

6. Shell Programming and Scripting

formating output

Hi all, I want to start a new topic on this matter I have this script, #!perl use strict; use warnings; use Data::Dumper; open my $log, '>', 'log-external.txt' or die "Could not open log: $!"; print $log "Subnet,Static,DHCP,Unused\n"; open my $dump, '>', 'dump.log' or die... (2 Replies)
Discussion started by: richsark
2 Replies

7. Shell Programming and Scripting

Problem In Formating Table as Output

Hi! I'm working a program that collects 4 various inputs and format my output into tabular form.Problem is my table margins move with different character lengths. Is there a way to fix my table margins even though the variables inside the table varies in length? thank you very much...:( (1 Reply)
Discussion started by: Lo11001
1 Replies

8. Shell Programming and Scripting

Output formating

Dear All I am stuck in one problem. Kindly help me. I am taking below mention file as input file and want some op file as mention below. Kindly send me all possible suggestion and query. Thnaks Jaydeep bELOW IS THE INPUT FILE: *** Connected to BSCANGR ***... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

9. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies

10. Shell Programming and Scripting

Formating cal output

Hi Gurus, In my Cal output i want to cut the date of 2nd saturday how tyo achive this. for eg in the below output i need that second saturday 13 to be cut. crypto $ cal January 2007 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26... (2 Replies)
Discussion started by: Krrishv
2 Replies
Login or Register to Ask a Question