婷婷综合国产,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 "\$?"
# 替換你要執行的命令
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,自動,登錄,的,幾段,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。

  • 相關文章
  • 下面列出與本文章《except自動登錄的幾段代碼分享》相關的同類信息!
  • 本頁收集關于except自動登錄的幾段代碼分享的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 湖州市| 内江市| 隆昌县| 桐柏县| 康马县| 黎川县| 三台县| 邵东县| 湖南省| 兰溪市| 桐柏县| 元朗区| 财经| 民权县| 东光县| 常山县| 三江| 五常市| 固始县| 潢川县| 陆河县| 修武县| 虹口区| 黎川县| 柯坪县| 衡山县| 吉水县| 泽州县| 长白| 古浪县| 石首市| 深州市| 遂昌县| 甘肃省| 中宁县| 思南县| 宁城县| 舒兰市| 南乐县| 武汉市| 辉南县|