Realization of shell without interaction_linux shell

Table of contents

  • foreword
  • 一、Here Document
    • 1.Here Document overview
    • 2. Basic grammatical format
    • 3.Here Document free interaction
    • 4. Variable setting (support variable replacement)
    • 5. Format Control
    • 6. Multi-line comments
  • Two, Expect
    • 1.Expect overview
    • 2. Basic installation of expect
    • 3. Basic commands
    • 4. Write scripts with expect
  • Summarize

foreword

Interaction-free means that when implementing a function, there is no need to continuously input information from the keyboard, and some actions are automatically completed through scripts or commands.

一、Here Document

1.Here Document overview

Use I/O redirection to provide a command list to an interactive program or command, such as the ftp, cat, or read commands.
HereDocument is a substitute for standard input, which can help script developers not have to use temporary files to build input information, but directly produce a file in place and use it as standard input for commands.

2. Basic grammatical format

command << markup
...
...
markup

# The special character "<<" precedes tags and commands, the purpose of this is to redirect the output of the command block to the stdin of the program and the command.
# Marks are selected to ensure that they do not appear elsewhere to avoid confusion; the content between the two marks is treated as a file and used as the standard input of the "command".
#Also Here Document can also be used with non-interactive programs and commands

Four points for attention:

  • Tags can use any legal characters;
  • The ending mark must be

Guess you like

Origin blog.csdn.net/shengyin714959/article/details/130329731