婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

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

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

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

復制代碼 代碼如下:

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

標簽:營口 宿遷 泰安 南京 西寧 昌都 臨滄 海口

巨人網絡通訊聲明:本文標題《except自動登錄的幾段代碼分享》,本文關鍵詞  except,自動,登錄,的,幾段,;如發(fā)現本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《except自動登錄的幾段代碼分享》相關的同類信息!
  • 本頁收集關于except自動登錄的幾段代碼分享的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 喀喇| 遂宁市| 宜章县| 神木县| 容城县| 安庆市| 六枝特区| 桐梓县| 乾安县| 仪陇县| 县级市| 手机| 高要市| 通州市| 沙雅县| 肥西县| 巧家县| 同江市| 庆安县| 兴国县| 长乐市| 延安市| 吉首市| 云梦县| 若尔盖县| 增城市| 绥芬河市| 桐庐县| 浮山县| 福贡县| 十堰市| 兰溪市| 梁河县| 南昌县| 潮安县| 柞水县| 磐石市| 南京市| 新平| 尼玛县| 盐源县|