运维自动化实战(一)Linux Shell 自动交互 发表于 2023-08-27 本文主要介绍自动化输入脚本的方式。 关键词:shell bash脚本输入方式 1echo -n "ServiceName\nOperator\nPassword" | upx login 输入每行文字后输入一个回车,某些情况不适用。 Expect脚本 123456789#!/bin/bash /usr/bin/expect <<-EOFset timeout 50spawn upx login expect "*ServiceName*" {send "ServiceName\r"}expect "*Operator*" {send "Operator\r"}expect "*Password*" {send "Password\r"}expect eofEOF expect 提示的字段是捕获输出,然后在后面跟着输入。