Installing expect[[email protected] ~]# yum install -y expectUse a script to log into a remote machineScripting 1.expectThe contents are as follows:[[email protected] expect]# vim 1.expect#!/usr/bin/expectset host "192.168.130.128" #定义变量set
Recent project requirements, need to write some shell script interaction, the pipeline is not enough time, expect can be very good to implement the interaction between the script, search for information, found that many articles on the Web are
Expect is a tool built on TCL to automate tasks that require interaction.Because expect is TCL-based, you need to have TCL installed in your systemHow to check?[Email protected] ~]# Whereis tclTcl:/usr/lib/tcl8.4/usr/share/tcl8.4If you do not see
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.
Use expect to implement automatic logon script, there are many online, but there is no clear explanation, beginners are generally copied, collection. But why do you want to write this but do not know it. This article uses a shortest example to
I. Introduction of ExpectExpect is a simple TCL-based scripting language tool, a software suite that enables automatic interaction, with the function of automating human-computer interaction, and the ability to "session" with an interactive program
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,
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
Use expect to implement automatic login script, there are many online, but there is no clear explanation, beginners are generally copied, collection. But why to write this but do not know it. This article uses a shortest example to illustrate the
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.