正所谓,会的不难,难的不会。
了解如何使用expect, 可以阅读O'Reilly的书: <<Exploring Expect>>
https://www.oreilly.com/library/view/exploring-expect/9781565920903/
For example, under Ubuntu:
#sudo apt update
#sudo apt install expect
#man expect
EXPECT(1) General Commands Manual EXPECT(1)
NAME
expect - programmed dialogue with interactive programs, Version 5
SYNOPSIS
expect [ -dDinN ] [ -c cmds ] [ [ -[f|b] ] cmdfile ] [ args ]
INTRODUCTION
Expect is a program that "talks" to other interactive programs accord‐
ing to a script. Following the script, Expect knows what can be ex‐
pected from a program and what the correct response should be. An in‐
terpreted language provides branching and high-level control structures
to direct the dialogue. In addition, the user can take control and in‐
teract directly when desired, afterward returning control to the
script.
。。。。。