Linux Shell Interactive Walkthrough

Source: Internet
Author: User

--stdin indicates that a standard input can be made with any file

Expect its main function is to add a shell to the SSH process to pass the interactive instructions.

Its core is the spawn expect send set

Spawn calling the command to execute

Expect waits for the command prompt to appear, which is the prompt to capture user input:

Send sends values that need to be interacted with instead of manually entering content by the user

Set Variable Value

Interact execution finishes maintaining interactive state

Expect EOF this must be added, corresponding to the spawn indicates that the capture terminal is completed and exited

Example:

[email protected] ~]# cat test.sh

#!/bin/bash

#

#!/bin/bash

#

Expect < set timeout-1

Spawn Mysql-uroot-p

Expect "Password:"

Send "123456\r"

Expect "mysql>"

Send "CREATE Database aaa;\r"

Expect "mysql>"

Send "exit\r"

Expect EOF

Eof




This article is from the "Andylinux" blog, make sure to keep this source http://andywen.blog.51cto.com/10283904/1739842

Linux Shell Interactive Walkthrough

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.