function myFunction()
{
var x=document.getElementById("fname");
document.getElementById("show").innerHTML="\n你好\n你的帳號"+x.value+"開好了";
}
slinbody 發表在 痞客邦 留言(0) 人氣(5)
#vi ssh-expect
===================
#!/usr/bin/expect
set timeout 60
slinbody 發表在 痞客邦 留言(0) 人氣(175)
#vi test.sh
-------------------------------
set device 10.0.0.1
set passwd [你的密碼]
spawn telnet $device
expect "Password:"
send "$passwd\n"
expect ">"
send "en\n"
expect "Password:"
send "$passwd\n"
send "ter len 0\r"
send "show ip int brief\r"
expect "GigabitEthernet0/2"
puts "$expect_out(buffer)"
slinbody 發表在 痞客邦 留言(0) 人氣(187)
#vi test.sh
-------------------------------------------
#!/usr/bin/expect -f
set host [lindex $argv 0]
set password [密碼填此處]
slinbody 發表在 痞客邦 留言(0) 人氣(382)
參考
expect要紀錄執行結果或輸出
可以用log_file這個指令
#!/usr/bin/expect -f
log_file -noappend /tmp/myfile.log
#log_file預設append or create if not exist
#若你要每次重新紀錄,要加上-noappend指令
另外
send_log也可以將送訊息到log_file指定的檔案
send_log "end of it"
log_file [args] [[-a] file]If a filename is provided, log_file will record a transcript of the session (beginning at that point) in the file. log_file will stop recording if no argument is given. Any previous log file is closed.
slinbody 發表在 痞客邦 留言(0) 人氣(291)
#vi myscript
#此script可一次帶多個參數
#依序執行
#!/usr/bin/expect -f
log_user 1
spawn telnet 1.1.0.2
sleep 1
expect "Login:"
send "admin\n"
expect "Password:"
send "1234\n"
sleep 2
slinbody 發表在 痞客邦 留言(0) 人氣(21)
#!/bin/sh
i=2
while [ $i -lt 5 ] //注意空格
do
zcat /var/log/ip.log.$i.bz2
i=`expr $i + 1`
done
slinbody 發表在 痞客邦 留言(0) 人氣(48)
#!/usr/bin/expect
log_user 0 //0不顯示輸出
spawn telnet 10.0.8.250
expect " Login Menu"
sleep 1
expect " Login: "
send "your account\r"
expect " Password: "
send "your passwd\r"
expect "Command>"
send "a\r"
expect "Command>"
send "p\r"
expect "Command>"
send "p\r"
send_user "Complete!!" //送訊息給user
interact
slinbody 發表在 痞客邦 留言(0) 人氣(183)
slinbody 發表在 痞客邦 留言(0) 人氣(134)