In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. outline
Overview of 1.Expect
2.Expect installation (underlying language Tcl)
3.Expect basic command
4.Expect execution mode
5.Expect case
I. Overview of Expect
1.Expect is a tool based on TCL language, and Expect is a tool for automatic control and testing. Mainly solve the problem of non-interactive in shell script. It is very helpful for large-scale linux operation and maintenance.
two。 In linux operation and development, we often need to log on to the server remotely. The login process is an interactive process, and Yuyao may enter yes/no password and other information. To simulate this input, you can use an Expect script.
II. Expect installation
1. Mount the CD
two。 Make a local YUM source
Execute the installation command: yum-y intall expect
III. Basic orders
1.send
Send a string to the process to simulate the user's input
This command cannot automatically enter to change the line, and usually add\ r (enter).
2.expect
An internal command of expect determines whether the specified string is included in the last output, and returns it immediately if so, otherwise it will return after waiting for the timeout.
You can only capture the output of processes started by spawn
3.spawn
Start the process and track subsequent interactions
4.interact
Maintain the interactive state after the execution is completed, and hand over the control to the console
5.Timeout
Specify the timeout period. If it expires, you will continue to execute subsequent instructions of the expect script.
Unit is: seconds
Timeout-1 for never timeout
By default, timeout is 10 seconds
6.exp_continue
Allow expect to continue to execute instructions down
7.send_user
Echo command, equivalent to echo
8.$argv parameter array
The Expect script can accept parameters passed from bash, which can be obtained using [lindex $argv n], where n starts at 0 and represents the first, second, and third, respectively. Parameters.
TIP
Expect scripts must end with interact or expect ecof, and expect eof is usually enough to perform automated tasks
Expect eof is really waiting for the end sign. Commands initiated by spawn end with an eof tag that expect eof is waiting for.
Fourth, the implementation of Expect:
Direct execution
V. case
Remote login
Embedded execution
Automatically exit after logging in to remote control
TIP
Explain here. "
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.