Mikrotik | Forum Mikrotik Indonesia   Mikrotik Manual Mikrotik iSPY Mikrotik RSS Feed
This Logo is a Courtesy from RumahDowty

Go Back   Mikrotik | Forum Mikrotik Indonesia > Diskusi Mikrotik RouterOS > Scripting @ Mikrotik
iSpy My iTrade Register FAQ Members List Calendar Mark Forums Read

Diskusi [Info] Script buat auto delete nice di address list dan auto import nice.rsc file pada Scripting @ Mikrotik | Mikrotik | Forum Mikrotik Indonesia : Ini hasil eksperimen hari ini supaya daftar nice di mikrotik bisa terupdate lewat script. NB: ...


Official Board Announcements
Donasi FMI
Forum Mikrotik Indonesia Road Show
Forum Mikrotik Indonesia Accessoris Contest



 
Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 09-07-2007, 10:50
okto_2005's Avatar
okto_2005 okto_2005 is offline
Member Super Senior
 
Join Date: Jul 2007
Posts: 645
iTrader: (0)
Thanks: 10
Thanked 391 Times in 119 Posts
okto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to behold
Send a message via Yahoo to okto_2005 Send a message via Skype™ to okto_2005
[Info] Script buat auto delete nice di address list dan auto import nice.rsc file




Ini hasil eksperimen hari ini supaya daftar nice di mikrotik bisa terupdate lewat script.

NB: tapi autodownload dari link mikrotik.co.id belum bisa. karena gue baca betul betul dari quote:
Quote:
Proses upload ini dapat juga dilakukan secara otomatis jika Anda memiliki pengetahuan scripting. Misalnya Anda membuat shell script pada Linux untuk melakukan download secara otomatis dan mengupload file secara otomatis setiap pk 06.00 pagi. Kemudian Anda tinggal membuat scheduler pada router untuk melakukan import file.
ini kayanya harus dari luar mikrotik box (lewat linux-box, yg mungkin bisa dari squidbox yg online 24jam terus)

Script:
/ip sys scr pr
name="scriptdelnice" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,pa ssword
last-started=jul/09/2007 10:19:59 run-count=1
source=
/ip firewall address-list remove [find list="nice"]
name="scriptimpnice" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,pa ssword
last-started=jul/09/2007 10:19:59 run-count=1
source=
/import nice.rsc

Schedule:
# NAME ON-EVENT START-DATE START-TIME INTERVAL RUN-COUNT
...
...
4 schdelnice scriptdelnice apr/16/2007 06:05:00 1d 0
4 schimpnice scriptimpnice apr/16/2007 06:05:05 1d 0

gue bagi 2 scriptnya supaya mikrotik ada delay 5 detik menghapus daftar nice yang panjang, lalu mengimport lagi filenya. (kalo diupdate langsung tanpa meremove daftar sebelumnya bisa apa enggak gue lum tau) eksperimen sendiri yah ^^, kalau ada script lebih bagus di revisi dibawah boleh2 aja.

mungkin rekan2 laen bisa menambahkan script di linux biar bisa donlot halaman web terus disimpan ke file nice.rsc, lalu upload lewat ftp ke mikrotik box

karena sampai sini gue ga paham betul script linux. (pake mikrotik aja barusan 6 bulan gara2 provider ngasi mikrotik, kalo ga gue ga belajar mikrotik hihihihihi).


Last edited by okto_2005 : 09-07-2007 at 11:00.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to okto_2005 For This Useful Post:
  #2 (permalink)  
Old 09-07-2007, 11:47
ponywaterhouse ponywaterhouse is offline
Forum Guru
 
Join Date: Jul 2007
Posts: 1,503
iTrader: (0)
Thanks: 60
Thanked 148 Times in 123 Posts
ponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura aboutponywaterhouse has a spectacular aura about
wah, hebat bang oto ini...
banyak sekali script2nya...

keep posting bro..

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-07-2007, 11:56
okto_2005's Avatar
okto_2005 okto_2005 is offline
Member Super Senior
 
Join Date: Jul 2007
Posts: 645
iTrader: (0)
Thanks: 10
Thanked 391 Times in 119 Posts
okto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to behold
Send a message via Yahoo to okto_2005 Send a message via Skype™ to okto_2005
hahaha masih banyak di luar sana yg mahir ^^.

ayo ayo siapa yg bisa script linux nya...

PS: gara2 eksperimen script ini, rule firewall gue ilang smua swt...
sebelum gue posting disini, ada salah ketik (yg gue garis bawah):
/ip sys scr pr
name="scriptdelnice" owner="admin"
policy=ftp,reboot,read,write,policy,test,winbox,pa ssword
last-started=jul/09/2007 10:19:59 run-count=1
source=
/ip firewall filt remove

gue rollback ke 1 minggu, yg ternyata..... ga ada mangle iix internasionalnya wah sedih gue... tulis satu2

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-07-2007, 12:04
[a]'s Avatar
[a] [a] is offline
Forum Advisor
 
Join Date: Jun 2007
Location: Jakarta
Posts: 1,732
iTrader: (1)
Thanks: 306
Thanked 744 Times in 223 Posts
[a] has disabled reputation
Send a message via Yahoo to [a]
salute to bro okto_2005 with his scripts and the will to share...


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-07-2007, 12:08
okto_2005's Avatar
okto_2005 okto_2005 is offline
Member Super Senior
 
Join Date: Jul 2007
Posts: 645
iTrader: (0)
Thanks: 10
Thanked 391 Times in 119 Posts
okto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to behold
Send a message via Yahoo to okto_2005 Send a message via Skype™ to okto_2005
setelah gue liat2 lagi postingan gue.... gue udah pernah export ke sini firewall rule gue.... kok ga kepikiran import aja yah.................

parah2 deh gue..... rollback huhuhuhuhuhuhu....

gue sih bisanya scripting dikit2 bro.. kalo disuruh bridging jaringan, seting hotspot gue ga bisa.. ga punya bahan eksperimennya...

yahh bisanya ke seputar programmingnya aja...


Last edited by okto_2005 : 09-07-2007 at 12:14.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-07-2007, 12:15
[a]'s Avatar
[a] [a] is offline
Forum Advisor
 
Join Date: Jun 2007
Location: Jakarta
Posts: 1,732
iTrader: (1)
Thanks: 306
Thanked 744 Times in 223 Posts
[a] has disabled reputation
Send a message via Yahoo to [a]
makanya ada forum ini kan...

ga ada orang yang bisa di semua bidang...pasti ada spesialisasi dan interestnya masing-masing...

disini sih diharapkan kita bisa saling bantu dah share pengalaman...

thanks bro...

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-07-2007, 12:59
okto_2005's Avatar
okto_2005 okto_2005 is offline
Member Super Senior
 
Join Date: Jul 2007
Posts: 645
iTrader: (0)
Thanks: 10
Thanked 391 Times in 119 Posts
okto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to behold
Send a message via Yahoo to okto_2005 Send a message via Skype™ to okto_2005
Setelah melihat2 forum tetangga, aku menemukan shell script yg bisa mengeluarkan kata selamat pagi / selamat siang.., ini bisa dijadikan dasar untuk auto download nice.
Code:
#!/bin/sh

date|awk '{
split($4, waktu,":");
print "Sekarang tanggal "$3" " $2" tahun "$6
print "Jam "waktu[1]" Menit "waktu[2]" Detik "waktu[3]
if (waktu[1]>4 && waktu[1]<=10)
{
print "Selamat pagi bro"
}
else if (waktu[1]>10 && waktu[1]<=15)
{
print "Selamat siang bro"
}
}'

#EOF
modifikasi script di atas, download memakai perintah wget (ini masih kerangka awal), mungkin ada temen2 laen yg bisa merevisinya, atau membetulkan jika ada yg salah.:

Code:
#!/bin/sh

date|awk '{
split($4, waktu,":");
print "Sekarang tanggal "$3" " $2" tahun "$6
print "Jam "waktu[1]" Menit "waktu[2]" Detik "waktu[3]
#download jam 6 pas
if (waktu[1]=6 && waktu[2]=0 && waktu[3]=0) 
{
wget -q -Y on http://www.mikrotik.co.id/getfile.php?nf=nice.rsc -O nice.rsc
}
#transfer ke mikrotik box memakai ftp jam 06:00:10
if (waktu[1]=6 && waktu[2]=0 && waktu[3]=10) 
{
ftp <mikrotik box>
<mode ascii on>
<put nice.rsc>
<quit>
}
}'

#EOF
script sampai sini dulu, transfer ke ftp-nya tolong dilanjutin, karena ga paham sama linux nih..., sekalian perintah wgetnya aku da tau itu betul apa engga, solanya copy paste dari tempat tempat laen.


Last edited by okto_2005 : 10-07-2007 at 13:08.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 4 Users Say Thank You to okto_2005 For This Useful Post:
  #8 (permalink)  
Old 17-07-2007, 13:37
nyoman nyoman is offline
Member
 
Join Date: Jul 2007
Posts: 111
iTrader: (0)
Thanks: 0
Thanked 18 Times in 14 Posts
nyoman will become famous soon enough
Mungkin untuk urusan waktu download serahkan ke crond (ini yang ada dikepalaku)

15 06 * * * root /root/bin/jalanin.aku.dong

file /root/bin/jalanin.aku.dong isinya:

Code:
#!/bin/bash
#pindah ke directory /var/tmp
cd /var/tmp 
#download file nice.rsc, jangan download jika filenya gak lebih baru.
wget -N http://www.mikrotik.co.id/getfile.php?nf=nice.rsc -O nice.rsc
#jalanin file upload.sh (memakai tools expect, karena protocol ftp perlu interaksi)
./var/tmp/upload.sh

# EOF jalanin.aku.dong
File /var/tmp/upload.sh isinya:
Code:
#!/usr/bin/expect
spawn ftp -i 192.168.xx.yy # ganti dengan host mikrotik kamu
expect "root): "
send "admin\r"
expect "assword:"
send "passwordkamu\r" # ganti dengan password mikrotik kamu
expect "ftp> "
send "lcd /var/tmp/\r" # sesuakan dengan lokasi tempat file nice.rsc
expect "ftp> "
send "put nice.rsc\r"
expect "ftp> "
send "bye\r"
#EOF upload.sh
Jangan lupa beri mod +x kedua file di atas
berikut logs nya
root@proxy:/var/tmp # ./jalanin.aku.dong
--14:35:19-- http://www.mikrotik.co.id/getfile.php?nf=nice.rsc
=> `nice.rsc'
Connecting to 192.168.83.xx:3128... connected.
Proxy request sent, awaiting response... 302 Moved Temporarily
Location: http://ixp.mikrotik.co.id/download/nice.rsc [following]
--14:35:35-- http://ixp.mikrotik.co.id/download/nice.rsc
=> `nice.rsc'
Connecting to 192.168.83.xx:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 19,014 (19K) [text/plain]

100%[====================================>] 19,014 9.89K/s

14:35:37 (9.87 KB/s) - `nice.rsc' saved [19014/19014]

spawn ftp -i 192.168.83.xx
Connected to 192.168.83.xx.
220 Mikrotik FTP server (MikroTik 2.9.6) ready
500 'AUTH': command not understood
500 'AUTH': command not understood
KERBEROS_V4 rejected as an authentication type
Name (192.168.83.xx:root): admin
331 Password required for admin
Password:
230 User admin logged in
Remote system type is UNIX.
ftp> lcd /var/tmp/
Local directory now /var/tmp
ftp> put nice.rsc
local: nice.rsc remote: nice.rsc
227 Entering Passive Mode (192,168,83,xx,144,157).
150 Opening ASCII mode data connection for '/nice.rsc'
226 ASCII transfer complete
19490 bytes sent in 0.0022 seconds (8.6e+03 Kbytes/s)
ftp>

Selesai...

Schatje

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to nyoman For This Useful Post:
  #9 (permalink)  
Old 17-07-2007, 15:05
okto_2005's Avatar
okto_2005 okto_2005 is offline
Member Super Senior
 
Join Date: Jul 2007
Posts: 645
iTrader: (0)
Thanks: 10
Thanked 391 Times in 119 Posts
okto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to beholdokto_2005 is a splendid one to behold
Send a message via Yahoo to okto_2005 Send a message via Skype™ to okto_2005
nah good job akhirnya bisa juga autodownload nice.rsc
tolong jelasin yg ini dong... auto downloadnya gimana cara setting:
Quote:
Mungkin untuk urusan waktu download serahkan ke crond (ini yang ada dikepalaku)

15 06 * * * root /root/bin/jalanin.aku.dong

ini typo ya?
Quote:
expect "assword:"
ini kok bisa gni knapa yah??? maap oon banget soal linux:
Quote:
500 'AUTH': command not understood
500 'AUTH': command not understood
KERBEROS_V4 rejected as an authentication type

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 10-11-2007, 14:15
sony's Avatar
sony sony is offline
Baru Gabung
 
Join Date: Nov 2007
Posts: 2
iTrader: (0)
Thanks: 0
Thanked 3 Times in 2 Posts
sony is on a distinguished road
Post Simple script

Baru gabung nih, tertarik scripting.

Download bisa menggunakan wget seperti yang sudah dibicarakan diatas
#wget -a file.log -O dst-file.rsc http://src-addr/nice.rsc
Upload bisa menggunakan wput
#wput -a file.log dst-file.rsc ftp://userasswd@server.mikrotik/nice.rsc
Ketik dalam satu file, misal script.sh, dan jalankan menggunakan cron.

ps: install wget dan wput klu blom ada di server *nix .
untuk schedule di mikrotik sudah dibahas diatas sebelumnya.

GoodLuck

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to sony For This Useful Post:
  #11 (permalink)  
Old 08-01-2008, 19:36
singgahpai's Avatar
singgahpai singgahpai is offline
Calon Member
 
Join Date: Aug 2007
Posts: 82
iTrader: (0)
Thanks: 5
Thanked 21 Times in 13 Posts
singgahpai will become famous soon enoughsinggahpai will become famous soon enough
Send a message via Yahoo to singgahpai
Iya nih bisa automatic download, upload dan import nice.rsc, tapi memang butuh bantuan komputer lain karena proses download nice.rsc gak bisa langsung di MT nya ya..
Berikut detailnya:

1. Buat script di server lain untuk download nice.rsc dari mikrotik.co.id dan upload ke MT, kalau saya pakai FreeBSD, scripting pakai Bash Script biasa.
Yang diperlukan adalah file wget dan wput seperti Mas Sony jelaskan di atas.
kalau belum ada bisa install aja pakai perintah: portinstall wget | portinstall wput

bikin script pakai mc atau vi, isinya:
Code:
#!/bin/sh
/usr/local/bin/wget -c http://ixp.mikrotik.co.id/download/nice.rsc
/usr/local/bin/wput -R nice.rsc ftp://username-MT:password-MT@IP-MT
Penggunaan option -R di perintah wput agar setelah di upload ftp ke MT, file nice.rsc dihapus di komputer ini, karena kalau masih ada file nice.rsc, perintah wget gak mau download file nice.rsc dari mikrotik.co.id

2. simpan dengan nama misalnya: exim-nice.sh
3. chmod 754 exim-nice.sh
4. Test jalankan dengan perintah ./exim-nice.sh
5. Sambil lihat prosesnya berhasil gak di taruh file nice.rsc di MT
6. Kalau sudah oke, masukkan dalam schedule crontab, dengan perintah crontab -e, ketikkan seperti ini:
Code:
35 6 * * * /usr/local/etc/exim-nice.sh
artinya setiap jam 6.35 akan jalankan file exim-nice.rsc
7. Masuk ke MT, bikin scheduler yang isinya:
Code:
/ system scheduler 
add name="remove-import-nice" on-event="/ip firewall address-list remove \
    \[find list=\"nice\"\]
\n/import nice.rsc
\n/file remove nice.rsc" \
    start-date=jan/08/2008 start-time=06:40:00 interval=1d comment="" \
    disabled=no
Schedule ini akan dijalankan setiap jam 6.40 dengan interval 24 jam, jadi setiap hari pada jam 6.40 akan jalan scriptnya.
Perlu ditambahkan perinah remove file nice.rsc karena kalau masih ada file nice.rsc di MT, script upload yang tadi sudah kita buat gak mau lanjut prosesnya, status FAILED.. jadi harus di remove file nice.rsc di MTnya..

He..he.he. jadi gak manual lagi deh sekarang..

Thanks Mas Oktobrima dan Mas Sony dan master-master yang lain


Last edited by singgahpai : 08-01-2008 at 19:40.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 14-01-2008, 03:09
tajid.yakub's Avatar
tajid.yakub tajid.yakub is offline
Baru Gabung
 
Join Date: Sep 2007
Location: Jakarta
Posts: 17
iTrader: (0)
Thanks: 2
Thanked 28 Times in 4 Posts
tajid.yakub is on a distinguished roadtajid.yakub is on a distinguished road
Send a message via Yahoo to tajid.yakub
Alamak..
ternyata sudah pernah dibahas sebelumnya toh ya..
tau gt ikut nimbrung dah..

http://www.forummikrotik.com/tutoria...-mikrotik.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 11-04-2008, 07:28
maman maman is offline
Calon Member
 
Join Date: Nov 2007
Posts: 82
iTrader: (0)
Thanks: 2
Thanked 97 Times in 25 Posts
maman is on a distinguished roadmaman is on a distinguished roadmaman is on a distinguished roadmaman is on a distinguished roadmaman is on a distinguished road
Pakai Mikrotik Ver 3.x ....... rasanya jauh lebih mudah

http://www.forummikrotik.com/tutoria...html#post15771

Semoga bermanfaat

| m | a | m | a | n |

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


This Forum is Powered by Orion Net.

All times are GMT +7. The time now is 08:32.