1. 程式人生 > >linux shell的自動互動

linux shell的自動互動

1、使用expect工具,如:

1)自動登陸

#!/usr/bin/expect
spawn ssh 使用者@IP
expect {
	"yes/no" { send "yes\r"; exp_continue}
	"password:" {
	send "密碼\r";
	interact
	}
}

1)expect使用spawn呼叫其他的執行程式

2)使用expect ,send 組合實現自動互動

3)interact 執行後保持互動狀態

2、使用重定向

不懂。。回頭再看