The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
very unusual question about while Terrible Shell Programming and Scripting 3 08-16-2006 02:21 AM
pleaseee help with unusual crontab problem amon SUN Solaris 4 05-10-2006 02:18 AM
unusual function refrences xbjxbj High Level Programming 11 02-22-2005 02:52 AM
unusual function refrences xbjxbj UNIX for Advanced & Expert Users 1 02-10-2005 12:27 AM
Deleting an unusual file scmay Shell Programming and Scripting 2 06-09-2004 10:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2004
ohhmyhead ohhmyhead is offline
Registered User
  
 

Join Date: Jul 2004
Posts: 5
Question somewhat unusual top output problem

i'm a relative newbie to unix (i'm on OSX) and i have a specific problem i'm tripped up on:

i'm piping the output of top (in log format) into an awk command which formats the information (and eventually will send it out continuously via udp/osc to another app). my problem is with what comes up in the terminal when i try running top -l1000 | awk -f filterfile. the samples pop up two at a time! i need for them to be at relatively constant intervals for this application. does anyone know why this might be happening? i've included my (simple and kludgy) awk file below. thanks in advance for any help.


----

$1 !~ /Processes:|Load|SharedLibs:|MemRegions:|PhysMem:|VM:|PID/ && $2 !~ /Window|AOL|awk|top|tcsh|login|lookupd|AppleSpell|iChatAgent|UniversalA|SystemUISe|pbs|DirectoryS|log inwindo|NortonMiss|cron|cupsd|inetd|automount|nfsiod|coreservic|netinfod|crashrepor|mDNSRespon|syslo gd|autodiskmo|NortonAuto|ATSServer|SecuritySe|configd|dynamic_pa|update|kextd|mach_init|init|kernel_ tas|fix_prebin|Norton|NortonMiss|SecurityAg|SETI@home_|SETI@homeI|S@hScreenS|System|CPU|Internet|DVD |Audio|Echo24|SuperColli|scsynth|MaxMSP|MIDIServer|Image|Key|Burning|Sloppy|Adobe/ { print $2, $3, $5, $6, $7 }
$2 ~ /Window|AOL/ { print $2$3, $4, $6, $7, $8 }
$2 ~ /MaxMSP/ { print $2, $4, $6, $7, $8 }
$2 ~ /Norton|Image|System|CPU|Internet|DVD|Audio|Echo24|Key|Burning|Sloppy|Adobe/ && $3 ~ /Caps|Ant|Pre|Capt|Monito|E|Player|Hija|Con|Mo|Sok|Phot/ { print $2$3, $4, $6, $7, $8 }
  #2 (permalink)  
Old 07-15-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
A reasonable guess would be buffering. A program like top may change its buffering stragety based on the output file. I don'y use OSX. Does your cat command have -u? If so try

top -l1000 | cat -u

I'll bet you get a similiar result.
  #3 (permalink)  
Old 07-15-2004
ohhmyhead ohhmyhead is offline
Registered User
  
 

Join Date: Jul 2004
Posts: 5
my cat does have -u but it's doin some odd things here. really doesn't change the way anything looks.

"top -l4 -s1" posts 1 sample a second.

"top -l4 -s1 | cat -u" posts 2 samples every 2 seconds.

"top -l4 -s1 | awk -f myfile" still posts 2 samples every 2 seconds.

oddly enough, adding cat -u to the end of my command causes it to wait until all of the samples have gone through before it posts anything. so "top -l4 -s1 | awk -f myfile | cat -u" waits four seconds and then posts all four samples at once.

it's interesting to see these differences. a little frustrating too, but interesting. =) could this be some buffering in the pipe?
  #4 (permalink)  
Old 07-16-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
The point of trying the "cat -u" instead of your awk script was to show that it's not the awk script. The top command is buffering the output.
  #5 (permalink)  
Old 07-17-2004
ohhmyhead ohhmyhead is offline
Registered User
  
 

Join Date: Jul 2004
Posts: 5
i wound up making a script that just loops the command for each sample. works well enough.

thanks for your help!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0