expect批量执行命令
生活随笔
收集整理的這篇文章主要介紹了
expect批量执行命令
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在跳板機(jī)上執(zhí)行腳本,登錄到遠(yuǎn)程機(jī)器分區(qū)格式化掛載命令
#/bin/bash passwd='engine' /usr/bin/expect << EOF set time 40 spawn ssh root@172.18.3.114 expect {"*yes/no" { send "yes\r"; exp_contine }"*password:" { send "$passwd\r" } } expect "*#" send "fdisk /dev/vda\r" expect -exact "Command (m for help):" send -- "n\r" expect -exact "Partition number (1-4, default 1):" send -- "1\r" expect -exact"First sector" send - "2048\r" expect -exact "Last sector, +sectors or +size{K,M,G}" send -- "1048575999\r" expect -exact "Command (m for help):" send -- "w\r" expect "*#" send "echo '/dev/vda1/home ext4 defaults 0 0' >> /etc/fstab \r" expect "*#" send -- "mkfs.ext4 /dev/vda1\r" expect "*#" send -- "mount -a\r" interact expect eof EOF?
總結(jié)
以上是生活随笔為你收集整理的expect批量执行命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python正则表达式尽可能小的匹配(遇
- 下一篇: 生产中的12种容器镜像扫描最佳实践