濮阳杆衣贸易有限公司

主頁 > 知識庫 > except自動登錄的幾段代碼分享

except自動登錄的幾段代碼分享

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

復制代碼 代碼如下:

#!/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

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

復制代碼 代碼如下:

[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

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

復制代碼 代碼如下:

#!/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

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

復制代碼 代碼如下:

#!/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 ...

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

復制代碼 代碼如下:

#!/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實現(xiàn)ssh自動登錄服務器并進行批量管理的實現(xiàn)方法
  • ssh expect自動登錄的腳本代碼
  • ssh自動登錄的4種實現(xiàn)方法
  • putty實現(xiàn)自動登錄的方法(ssh和ssh2)

標簽:營口 宿遷 泰安 南京 西寧 昌都 臨滄 巨人網(wǎng)絡通訊聲明:本文標題《except自動登錄的幾段代碼分享》,本文關(guān)鍵詞  except,自動,登錄,的,幾段,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。

  • 相關(guān)文章
  • 下面列出與本文章《except自動登錄的幾段代碼分享》相關(guān)的同類信息!
  • 本頁收集關(guān)于except自動登錄的幾段代碼分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    资中县| 嘉峪关市| 大厂| 廉江市| 巴南区| 新乡县| 孙吴县| 黄龙县| 双牌县| 平湖市| 页游| 阿坝县| 舒城县| 定结县| 富阳市| 文山县| 温泉县| 古田县| 阳西县| 旅游| 吕梁市| 铜山县| 鲁山县| 慈溪市| 卫辉市| 商丘市| 福清市| 泉州市| 牡丹江市| 芮城县| 黔南| 龙山县| 闻喜县| 金秀| 衢州市| 安西县| 林西县| 盈江县| 博野县| 壤塘县| 运城市|