[ns] parsing trace files

Ankit Agarwal ankit_agarwal@yahoo.com
Mon Apr 22 09:25:01 2002


Nino,

If you use 'awk' then you don't require the program
'columns'.

Take a look at:

http://www.ee.surrey.ac.uk/Personal/L.Wood/ns/

for some sample scripts with 'awk'. They're much
easier than what you have shown here.

In order to run an 'awk' script on a trace file, the
following command can be used:

awk -f awkscript.awk nstrace.tr > awkscript.out

Ofcourse, you will substitute your own file names.

Hope this helps.

Ankit.

--- "Nino.Kubinidze" <Nino.Kubinidze@ul.ie> wrote:
> 
> Hello,
> I've got a problem in parsing trace files.
> According to "NS by Example" at
> http://nile.wpi.edu/NS/analysis.html I have
> downloaded a program column, written in perl and
> made it executable. (I am
> attaching it at the end of the letter). Then I had
> to apply this shell
> command combined with awk:
> 
> cat /my_files/.../out.tr | grep " 2 3 cbr " | grep
> ^r | column 1 10 | awk
> '{dif = $2 - old2; if(dif==0) dif = 1; if(dif > 0)
> {printf("%d\t%f\n", $2,
> ($1 - old1) / dif); old1 = $1; old2 = $2}}' >
> jitter.txt 
> which gives me the following output:
> 
> column: Command not found
> 
> And I don't understand where is the problem. 
> Could anyone let me know how to make them working,
> please?
> Thanks,
> 
> Nino
> 
> P.S. Column
> 
> #!/usr/bin/perl
> 
> # Mark Claypool
> # Last significantly modified: April 27, 1994
> 
> # This program prints out fields of an indicated
> column.
> # The columns are numbered 1, 2, 3 ...
> 
> &ParseCommandLine;
> $line = ;
> while ($line) {
>     $line =~ s/^\s+//;            # remove initial
> white-space
>     $line =~ s/\s+/ /g;           # turn
> double-space into single space
>     @word = split('\s+',$line);   # columns will
> then be $1, $2, $3 ...
>     $i =0;			# 
>     while ($i <= $#col) {
>         print "@word[@col[$i]]\t";
> 	$i += 1;
>     }			
>     print "\n";
>     $line = ;
> }
> exit;
> 
>
#######################################################################
> # ParseCommandLine
> # check for the right number of command line
> arguments
> # print usage message and quit if there is an error
> # global variables are @col
> sub ParseCommandLine 
> {
>     while ($#ARGV >= 0) {
> 	$arg = shift(@ARGV);
> 	if ($arg =~ /^(\d+)/) {
> 	    push(@col, $1);
> 	} else {		
> 	    &usage;
> 	}
>     }
>     if ($#col < 0) {
> 	&usage;
>     }
> 
> }		
> 
> 
> # usage
> # print a usage maessage and quit
> sub usage
> {
>     print STDERR "column: print fields from an
> indicated column\n";
>     print STDERR "Usage: column , where flags
> are:\n";
>     print STDERR "       {# [#...]}\tcolumn(s) to
> print, numbered
> 0,1,2...\n"; 
> 	exit;
> 
> }
> 


=====
"Tough times do not last, only tough people do."
"A ship in the harbor is safe...but thats not what ships were made for."
"Do, or do not. There is no try." (Yoda)
Ankit Agarwal
5000 Oak Street, #815, Kansas City, MO 64112.
Telephone: (816) 531-4186. Email: ankit_agarwal@yahoo.com

__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/