發表文章

目前顯示的是 1月, 2019的文章

[Linux] Shell Script 語法

#兩個『 ` 』中間為可以先執行的指令,亦可使用 $( ) set str = 'Current directory is '`pwd` echo "Output : $str" ------------------------------------------------------ Output : Output : Current directory is /Users/Project/Test By Hao★

[Linux] Shell Script "==" and "=~"

# "==" set text0 = "World" set text1 = "World" set text2 = "Hello World" set text3 = "Hello World !!" if( $text2 == $text3) then echo "$text2 == $text3" else echo "$text2 != $text3" endif if( $text0 == text1) then echo "$text0 == $text1" else echo "$text0 != $text1" endif ------------------------------------------- output: Hello World !! != Hello World !! World == World # "=~" set text1 = "World" set text2 = "Hello World" set text3 = "Hello World !!" if( $text3 =~ $text2) then echo "$text2 is $text3 Substring" else echo "$text2 not $text3 Substring" endif if( $text2 =~ text1) then echo "$text1 is $text2 Substring" else echo "$text1 not $text2 Substring" endif ------------------------------------------- output: Hello World is Hello World !! Substring World is Hello World Substring By Hao★

[Network] NS2 simulator

圖片
  #Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 } #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Give node position (for NAM) $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos