全站数据
8 4 2 0 5 8 1

expect语句什么情况下执行

网络维修弱电工程 | 简单学习,快乐成才!         
问题更新日期:2024-10-16 07:22:43

问题描述

expect语句什么情况下执行急求答案,帮忙回答下
精选答案
最佳答案

给你一个例子,注意发命令时加一个

r:

[code=BatchFile]#! /usr/bin/expect

spawn su test

expect {

"Password:" {

send -- "test

r";

};

"$" {

send "ls /

r";

send "su root /

r";

expect {

"Password:" {

send -- "rootpw

r";

};

}

exit;

};

}

[/code]