總網頁瀏覽量

2013年5月17日 星期五

ShellScript

chmod +x run-VMCA.sh
改變檔案權限,使檔案可執行+x



#
#    VMCA = 0, NMCS = 1, NALM = 2, AMACAD = 3 , VMACA = 4
#pro = 0 1 2 3 4



#sp = 15 20 25 30 35
#sp is speed
#represent for different scenario
#ex:scenario/freeway_200nodes_20km_$sp.tcl




DATE=`date +%F-%H-%M`
//抓取日期與時間

FILE1=Analys_AMACAD/CHlifetime/"AMACAD-"$DATE"-avgCHlifetime.txt"
FILE2=Analys_AMACAD/CMlifetime/"AMACAD-"$DATE"-CMlifetime.txt"
#FILE3=VMCA/"VMCA-"$DATE"-.txt"
#FILE4=VMCA/"VMCA-"$DATE"-CMlifetime.txt"


if [ ! -d Analys_AMACAD ]
then
    mkdir Analys_AMACAD
fi
//fi表示 if then敘述結束的意思


#echo $DATE > $FILE1
#echo $DATE > $FILE2
#echo $DATE > $FILE3
#echo $DATE > $FILE4


for pro in 3
do

case $pro in
0) proto="VMCA";;
        1) proto="NMCS" ;;
        2) proto="NALM" ;;
        3) proto="AMACAD" ;;
        4) proto="VMACA";;
 
    esac
//同理 switch case結束

//以for loop跑不同移動劇本檔案
for sp in 15 17.5 20 22.5 25 27.5 30 32.5 35
do

echo "$pro"
#rm $prto-headlifetime.txt
echo "../ns freeway.tcl $proto scenario/freeway_200nodes_20km_$sp.tcl"
../ns freeway.tcl $pro scenario/freeway_200nodes_20km_$sp.tcl
//採用$pro協定以及,scenario底下的freeway_200nodes_20km_$sp.tcl移動劇本檔執行freeway.tcl


    cp $proto-headlifetime.txt Trace/$proto/$proto-CH-speed-$sp-Date-$DATE.txt
       cp $proto-memberduration.txt Trace/$proto/$proto-CM-speed-$sp-Date-$DATE.txt
//不論跑任何協定C語言輸出的檔名都一樣
//將C語言輸出的結果,複製到以協定名稱命名的檔案

rm $proto-headlifetime.txt
rm $proto-memberduration.txt
//將C語言跑出的檔案刪掉

echo "awk -f chlifetime.awk $proto-headlifetime.txt............."

awk -v speed=$sp -f chlifetime.awk Trace/$proto/$proto-CH-speed-$sp-Date-$DATE.txt >> $FILE1
//執行awk檔案針對C語言輸出的數據做加總與平均運算


echo "awk -f memberifetime.awk $proto-memberlifetime.txt............."

awk -v speed=$sp -f memberlifetime.awk Trace/$proto/$proto-CM-speed-$sp-Date-$DATE.txt >> $FILE2




#awk -v speed=$sp -f chlifetime.awk Trace/$proto/$proto-speed-$sp-Date-2012-06-17-15-37.txt >> $FILE1


done


done

沒有留言:

張貼留言