bash - 如何将非交互式参数传递到使用“读取”的 bash 文件中?
问题描述
我有以下 shell 脚本:
#! /bin/bash
. shell_functions/commonShellFunctions.sh
. shell_functions/settings.sh
_valid_url=1
echo "Welcome to HATS Accessibility Testing Tool!"
echo "We recommend using Chrome browser for the best experience."
echo "What would you like to scan today?"
options=("sitemap file containing links" "website")
select opt in "${options[@]}"
do
case $opt in
"sitemap file containing links")
scanType="sitemap"
crawler=crawlSitemap
prompt_message="Please enter URL to sitemap: "
break;;
"website")
prompt_website
break;;
"exit")
exit;;
*)
echo "Invalid option $REPLY";;
esac
done
read -p "$prompt_message" page
echo $page
它旨在提示用户,但是我希望在 CI 设置中使用脚本,在该设置中我通过控制台传递参数而不提示。
我目前正在使用echo "<ARG1>\n<ARG2>" | bash run.sh
,但我想知道是否有更好的方法来做到这一点。
解决方案
使用此处的文档
./run.sh <<EOF
arg1
arg2
EOF
推荐阅读
- node.js - 如何在rabbitmq(rascal.js)上管理每个请求的发布连接
- javascript - 在纯 JavaScript 中将一个存储单元转换为另一个
- ruby-on-rails - ruby gem 问题未初始化常量
- python-3.x - 嗨,我想遍历 numpy 数组以仅显示 2656 个图像中的 100 个图像
- docker - Jenkins - 使用 jenkins 凭证在登台服务器上的“docker login”
- http - 检测来自聊天应用程序(Facebook messenger、WhatsApp、Slack、Teams、Telegram 等)的元数据请求
- outlook - Exchange Online 公用文件夹中的电子表格和文档是什么
- android - 单一材质 带图像的切换按钮
- python - Need help on LMGTFY(Search) command for discord.py
- javascript - 如何使用 onclick 侦听器从元素中选择数据?