久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      linux中expect的用法是什么

      在linux中,expect是一個(gè)自動(dòng)化交互套件,主要應(yīng)用于執(zhí)行命令和程序時(shí),系統(tǒng)以交互形式要求輸入指定字符串,實(shí)現(xiàn)交互通信,執(zhí)行語法為“yum install -y expect”;該腳本能夠執(zhí)行的前提是需要安裝expect。

      linux中expect的用法是什么

      本教程操作環(huán)境:linux7.3系統(tǒng)、Dell G3電腦。

      linux中expect的用法是什么

      expect是一個(gè)自動(dòng)化交互套件,主要應(yīng)用于執(zhí)行命令和程序時(shí),系統(tǒng)以交互形式要求輸入指定字符串,實(shí)現(xiàn)交互通信。

      expect自動(dòng)交互流程:

      spawn啟動(dòng)指定進(jìn)程—expect獲取指定關(guān)鍵字—send向指定程序發(fā)送指定字符—執(zhí)行完成退出.

      注意該腳本能夠執(zhí)行的前提是安裝了expect

      yum install -y expect

      expect常用命令總結(jié):

      • spawn 交互程序開始后面跟命令或者指定程序

      • expect 獲取匹配信息匹配成功則執(zhí)行expect后面的程序動(dòng)作

      • send exp_send 用于發(fā)送指定的字符串信息

      • exp_continue 在expect中多次匹配就需要用到

      • send_user 用來打印輸出 相當(dāng)于shell中的echo

      • exit 退出expect腳本

      • eof expect執(zhí)行結(jié)束 退出

      • set 定義變量

      • puts 輸出變量

      • set timeout 設(shè)置超時(shí)時(shí)間

      示例:

      1.ssh登錄遠(yuǎn)程主機(jī)執(zhí)行命令,執(zhí)行方法 expect 1.sh 或者 ./1.sh

      # vim 1.sh  #!/usr/bin/expect spawn ssh saneri@192.168.56.103 df -Th expect "*password" send "123456n" expect eof

      2. ssh遠(yuǎn)程登錄主機(jī)執(zhí)行命令,在shell腳本中執(zhí)行expect命令,執(zhí)行方法sh 2.sh、bash 2.sh 或./2.sh都可以執(zhí)行.

      #!/bin/bash passwd='123456' /usr/bin/expect <<-EOF set time 30 spawn ssh saneri@192.168.56.103 df -Th expect { "*yes/no" { send "yesr"; exp_continue } "*password:" { send "$passwdr" } } expect eof EOF

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)