modul script
Embed Size (px)
TRANSCRIPT

Script
Divisi TrainingDepartemen TeknikPT UFOAKSES SUKSES LUAR BIASAJakarta

Fungsi script
Memaintenance task beberapa routerMengeksekusi perintah konsol berdasarkan waktuatau eventMenaikkan kecepatan task pada sebuah routerScript terdiri dari perintah konfigurasi dan expresi ( ICE = internal console expression )

Bagaimana menulis script
Mengunakan /system/script menu− Contoh : /system script add name=test source = {:log
info”heloo world !” }
Menulis langsung dikonsol− Contoh : [[email protected]]>:log info”heloo world!”

Sintaks perintah consolePrefix = perintah expression seperti pada root level− [[email protected]] > ip dns /ping 192.168.3.1 − [[email protected]] /log> ..
Path = Relative path ke menu level− [[email protected]] /ip firewall mangle> .. − [[email protected]] /ip firewall>
Path_args
Action− Seperti add – action =ip firewall filter add chain=forward
Name[=value]− /interface wireless set wlan1 ssid=nico

Contoh perintah console
/ping 10.0.0.1 count=6− Prefix= /− Action=ping− Unamed parameter= 10.0.0.1− Name[=value]= count=6
.. Ip firewall rule input− Path= ..ip firewall rule− Path_args = input

:for I from=1 to=10 do {:put $i}− Prefix= :− Action = for− Unnamed parameter= I− Pname[=value] = from=1 to=10 do {:put $i}
/interface monitor-traffic ether1,ether2,ether3,vlan− Prfefix= /− Path = interface− Action = monitor-traffic− Unnamed parameter = ether1,ether2,ether3,vlan

Berhitung dgn script[[email protected]] > :put (1+2)3[[email protected]] > :put (43-3)40[[email protected]] > :put (43*3) 129[[email protected]] > : put (45+23+1)69[[email protected]] > : put ( 10 / 2 )5

Perintah :
[[email protected]] > : environment do for len parse set toidtostrterminal error foreach local pick time toip totimebeep execute global log put toarraytoip6 typeofdelay find if nothing resolve tobooltonum while

Menulis script via winbox

Bagaimana menjalankan script
Perintah run− /system script run test
Menambahkan nama script pada tool task− /system scheduler add name=test on-event=test
interval=10s
Dimana saja dari konsol− :put “ hai”

Mengedit script
Menggunakan perintah set− /system script set script_name source={…}
Menggunakan editor− /system script edit script_name source
Full screen editor tidak jalan di single line mode

Monitoring script
Mengecek script counter dengan perintah print− /system script print
Melihat jalannya script− /system script job print

Variable dalam script
Mengunakan simbol $Global= system wide− :global a ; :set a 5; :put $a
Local− :local e; :set e 11 :put $e
Loop− :foreach s in 1,2,3 do={put $s}
Monitoring− /interface eth1 monitor ether1 do={:put $status}

Contoh penggunaan variable
[[email protected]] > :global g1 "nico mau belajarvariabel"[[email protected]] > :put $g1nico mau belajar variabel[[email protected]] > : global g2 "alooo"[[email protected]] > :global g1 g2

Tipe data
ListInternal numberNumberIP addressTimeBoolenstring

Konversi tipe data
Fungsi untuk konversi data adalah− toarray− tobool− toid− toip− tonum− tostr− totime

Perintah Get dan find
Get[[email protected]] > :put [/ip address get 0 address ]12.12.12.5/24Find[[email protected]] > /interface enable [find type=ether]

Contoh tipe dataHexadesimal[[email protected]] > :global var 0x10[[email protected]] > :put $var16Waktu[[email protected]] > :put 2d11h122d11:00:12Waktu dengan deimal[[email protected]] > :put 0.1d1.4s0.1d1.4s

[[email protected]] > : beep[[email protected]] > : beep length=2s frequency=10000

Script EditorDigunakan untuk merubah script
[[email protected]] > sys scr add name=aku
[[email protected]] > sys scr pr
Flags: I - invalid
0 name="tes" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff run-count=0 source=:log info " weleh-weleh "
1 name="nico" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff run-count=0 source=:put "heloo aku disini"
2 name="aku" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,password,sniff run-count=0 source=""
[[email protected]] > sys scr edit
number: 2
value-name: source

Script editor di winbox