Expect everywhere.
The first time I saw expect this command was the first time I was in full volume that's one of the company's cows. A set of automatic deployment, MD5, release of the full online tool written by the shell script, when it's okay,
background: In the remote file download, you need to enter the other party's server password, the shell does not support interactive input content, can be implemented in the following two ways I. Embedding expect in shell scripts for password
expect is a process for interacting 's command. With expect, we can write the interactive process on a script so that it is done automatically. The image of the said, SSH login, FTP login and so on are consistent with the definition of interaction.
Where the shell script needs to interact with the here document is the implementation, but some commands require the user to manually go on the interaction such as passwd, SCP
It is very painful to eliminate user interaction for automatic deployment,
Original address: http://www.nginx.cn/1934.htmlWhere the shell script needs to interact with the here document is the implementation, but some commands require the user to manually go on the interaction such as passwd, SCPIt is very painful to
Expect is a tool for dealing with interactions, usually for scenarios where you need to enter data manually, and you can use expect in your scripts to automate. installation
First check to see if there are any installed expect in the system.
#
Expect detailed
The expect command is simply to implement tools that automatically interact in interactive software through its built-in commands.
SSH can be used in conjunction with the Spawn command to achieve automatic SSH login. And because it
usage1. [#!/usr/bin/expect]This line tells the code in the operating system script to use that Shell to execute. The expect here is actually a kind of thing with bash under Linux and cmd under Windows.Note: This line is required on the first line of
In shell development, when we connect to FTP or passwd or sudo, we need to enter the password manually. This is obviously inappropriate for automation. And expect's strong interaction model solves this problem. I am involved in this work, the
Here is the script implementation process:1. Automatically package the backup on the server to a Web directory (of course this web directory is inaccessible to other people), so that the script to download.2. Download the backup package on the local
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.