#!/bin/csh

if ( "$1" == "" ) then
        echo ""
        echo "usage: $0 <restlessness>"
        echo ""
        exit
endif

if ( ! -d scenarios || ! -d logs ) then
        echo ""
        echo "cant find a necessary directory."
        echo ""
        exit
endif

setenv REST 1.0
echo $REST
shift

#echo $1
while( "$1" != "")

        setenv sfile scenarios/i-need-sleep-$1
        setenv lfile logs/i-need-sleep-$1

        time ../ns scripto.tcl -stop 600 -nn 50 -tr $lfile -sc $sfile
        if($status != 0) then
                echo "Error: ns"
                exit
        endif

        time perl totals $lfile 50 > $lfile.totals

        foreach f ($lfile $lfile.totals)
                gzip $f
                if($status != 0) then
                        echo ""
                        echo "Error: gzip $lfile"
                        echo ""
                        exit
                endif

                scp $f.gz jorjeta@bush.monarch.cs.cmu.edu:/bigdisk/aodv/logs/
                if($status == 0) then
                        rm $f.gz
                endif
        end

        shift
end

