**
自動遠端拷貝expect指令碼
expect自動遠端拷貝指令碼,利用rsync命令,指令碼內容如下:
#!/usr/bin/expect --用法:proc
usage_exit
ifelseif
else
}elseif
elseif
else
}else
expect
"yes/no)?"
"fatal"
timeout
"no route to host"
"connection refused"
"connection refused"
"host key verification failed"
"illegal host key"
"connection timed out"
"interrupted system call"}}
if"yes/no)?"}}
if}}expect
eof
}
./scp.exp
usage: ./
scp.
exp ip user passwd port sourcefile destdir direction bwlimit timeout
sourcefile
:a file
ordirectory to be transferred
需要拷貝目錄時目錄名後不要帶
/,否則會拷貝該目錄下的所有檔案
destdir
:the location that the sourcefile to be put
into
direction
:pull
orpush
pull
:remote
->
local
push
:local
->
remote
bwlimit
:bandwidth limit
,kbit/s
,0means
nolimit
timeout
:timeout of expect,s
,-1means
notimeout
expect 自動互動指令碼
命令列引數 ar 引數陣列,使用 lindex ar n 獲取,ar 0為指令碼名字 argc,引數個數 set username lindex ar 1 獲取第1個引數 set passwd lindex ar 2 獲取第2個引數 set timeout 30 設定超時 spawn是expect內...
EXPECT 指令碼 批量 遠端互動
在shell自動部署專案中對自動部署免去使用者互動很痛苦 expect eof 這個一定要加,與spawn對應表示捕獲終端輸出資訊終止,類似於if.endif expect指令碼必須以interact或expect eof結束,執行自動化任務通常expect eof就夠了。設定expect永不超時。...
scp遠端拷貝expect實現SHELL
在linux上,我們可以很方便的使用scp命令來遠端拷貝檔案,但是由於scp命令本身無儲存密碼選項,所以在shell裡面無法像samba那樣子儲存密碼,比較麻煩,下面介紹下兩種實現方法。方法一 scp 遠端拷檔案,建議用搭配 ssh 方法 1 在客戶機上生成 ssh 需要的 rsa 金鑰 ssh k...