濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > except自動(dòng)登錄的幾段代碼分享

except自動(dòng)登錄的幾段代碼分享

熱門標(biāo)簽:艾比利外呼系統(tǒng) 陜西便宜電銷機(jī)器人軟件 杞縣地圖標(biāo)注app 免費(fèi)門店地圖標(biāo)注注冊(cè)入駐 衡水外呼線路解決 電話機(jī)器人每天搜索多少次 ??谥悄苷Z音電銷機(jī)器人好用嗎 昆明電話外呼系統(tǒng)好么 外呼系統(tǒng)一天耗費(fèi)多少流量

復(fù)制代碼 代碼如下:

#!/usr/bin/expect -f
set timeout 30
set host "192.168.1.198"
spawn ssh $host
expect_before "no)?" {
send "yes\r" }
sleep 1
expect "password:"
send "123456\r"
expect "*#"
send "echo my name is fivetrees > /root/fivetrees.txt\r"
interact

##----------------------------

復(fù)制代碼 代碼如下:

[root@fivetrees ~]# cat expect
#!/usr/bin/expect
for {set i 10} {$i = 12} {incr i} {
set timeout 30
set ssh_user [lindex $argv 0]
spawn ssh -i .ssh/$ssh_user abc$i.com
expect_before "no)?" {
send "yes\r" }
sleep 1
expect "password*"
send "hello\r"
expect "*#"
send "echo hello expect! > /tmp/expect.txt\r"
expect "*#"
send "echo\r"
}
exit

##-------------------------

復(fù)制代碼 代碼如下:

#!/usr/bin/expect
if {$argc!=2} {
    send_user "usage: ./expect ssh_user password\n"
    exit
}
foreach i {11 12} {
set timeout 30
set ssh_user [lindex $argv 0]
set password [lindex $argv 1]
spawn ssh -i .ssh/$ssh_user root@xxx.yy.com
expect_before "no)?" {
send "yes\r" }
sleep 1
expect "Enter passphrase for key*"
send "password\r"
expect "*#"
send "echo hello expect! > /tmp/expect.txt\r"
expect "*#"
send "echo\r"
}
exit

##---------------------------

復(fù)制代碼 代碼如下:

#!/usr/bin/expect
set timeout 20
if {$argc 1} {
  puts "Usage: script IP"
  exit 1
}
# 替換你自己的用戶名
set user "username"
#替換你自己的登錄密碼
set password "yourpassword"
foreach IP  $argv {
spawn  ssh $user@$IP
expect \
  "(yes/no)?" {
    send "yes\r"
    expect "password:?" {
      send "$password\r"
    }
  } "password:?" {
    send "$password\r"
}
expect "\$?"
# 替換你要執(zhí)行的命令
send "last\r"
expect "\$?"
sleep 10
send "exit\r"
expect eof
}
使用方法
script_name   ip1  ip2  ip3 ...

##---------------------

復(fù)制代碼 代碼如下:

#!/bin/sh
# -*- tcl -*- \
exec tclsh $0 "$@"
package require Expect
set username [lindex $argv 0]
set password [lindex $argv 1]
set argv [lrange $argv 2 end]
set prompt "(%|#|\\$) $"
foreach ip $argv {
    spawn ssh -t $username@$ip sh
    lappend ids $spawn_id
}
expect_before -i ids eof {
    set index [lsearch $ids $expect_out(spawn_id)]
    set ids [lreplace $ids $index $index]
    if [llength $ids] exp_continue
}
expect -i ids "(yes/no)\\?" {
    send -i $expect_out(spawn_id) yes\r
    exp_continue
} -i ids "Enter passphrase for key" {
    send -i $expect_out(spawn_id) \r
    exp_continue
} -i ids "assword:" {
    send -i $expect_out(spawn_id) $password\r
    exp_continue
} -i ids -re $prompt {
    set spawn_id $expect_out(spawn_id)
    send "echo hello; exit\r"
    exp_continue
} timeout {
    exit 1
}

您可能感興趣的文章:
  • 用expect實(shí)現(xiàn)ssh自動(dòng)登錄服務(wù)器并進(jìn)行批量管理的實(shí)現(xiàn)方法
  • ssh expect自動(dòng)登錄的腳本代碼
  • ssh自動(dòng)登錄的4種實(shí)現(xiàn)方法
  • putty實(shí)現(xiàn)自動(dòng)登錄的方法(ssh和ssh2)

標(biāo)簽:營口 宿遷 泰安 南京 西寧 昌都 臨滄 ???/a>

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《except自動(dòng)登錄的幾段代碼分享》,本文關(guān)鍵詞  except,自動(dòng),登錄,的,幾段,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《except自動(dòng)登錄的幾段代碼分享》相關(guān)的同類信息!
  • 本頁收集關(guān)于except自動(dòng)登錄的幾段代碼分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    陇川县| 准格尔旗| 苗栗县| 汤原县| 灵璧县| 乌拉特中旗| 红安县| 于都县| 桐乡市| 崇文区| 朔州市| 张家口市| 永善县| 余干县| 隆尧县| 仙居县| 若尔盖县| 井陉县| 丹棱县| 额尔古纳市| 囊谦县| 荔浦县| 天水市| 静乐县| 长葛市| 拉萨市| 金秀| 曲松县| 兴安县| 南康市| 铜陵市| 新竹市| 荔波县| 湛江市| 西乌珠穆沁旗| 绥化市| 武功县| 武宁县| 梧州市| 黔西县| 湟源县|