beginer : shell script
well, skrg tiba2 butuh harus coding pake shell script, untung ada mas google yang baik hati.
after dibantu sm mas artikel dari bbrp site, ahirnya scriptnya jalan,
intinya mau buat script utk masuk ke mesin lain, trs harus eksekusi bbrp comand, kl sdh jalan, baru di schedule pk crontab..
- karena mau telnet, katanay harus pakai aplikasi "expect" –> apt-get install expect
- hbs itu buat contoh scriptnya,
#!/usr/bin/expect
set myServer x.x.x.x
set myUsername username
set myPassword userpassword
#login
# buka sesion telnet
spawn telnet $myServer
expect "username:"
# kirim info user login
send "$myUsername\r"
expect "password:"
expect "%"
send "$myPassword\r"
expect "%"
# contoh perintah, pake ping ya yg mudah
send "ping yahoo.com\r"
expect "%"
expect "%"
# Exit ,
send "exit\r"
expect eof - habis itu bs disave dan coba di eksekusi, misal di save pake nama test.sh, maka di eksekusi,
caranya pake ./test.sh - gagal?!
nah itu dia, tks lagi buat mas google.. stlh nyari2, ternyata ga akan bs dieksekusi sblm di buka permissionnya
chmod go+rx test.sh - coba eksekusi lagi ./test.sh
- gud lack :p
