bash - add answer to first commands question in shell script
问题描述
I have a first command in .sh file i.e.
cassandras3 backup --keyspace jl_powereasy_kespace --bucket database-backup-rds
This command asks a question when we run i.e.
Your cassandra data directory [/var/lib/cassandra/data]:
how can I confirm this answer in shell script. I need to press enter for this confirmation automatically.
root@ip-172-31-2-150:/home/ubuntu# /bin/bash /var/cassandra_backupV1.sh
Your cassandra data directory [/var/lib/cassandra/data]:
解决方案
As mentioned here, you can try running the command with echo as follows
echo -ne '\n' | cassandras3 backup --keyspace jl_powereasy_kespace --bucket database-backup-rds
or simply
echo | cassandras3 backup --keyspace jl_powereasy_kespace --bucket database-backup-rds
推荐阅读
- continuous-integration - Maven 命令行参数中的 TeamCity 双引号问题
- javascript - 赋值表达式中的左侧无效
- c++ - 将整数类型转换为枚举:函数转换与初始化
- go - 将通道参数传递给golang中的动态加载函数
- javascript - Javascript 代码返回 Unhandled Promise Rejection: AbortError: The operation was aborted
- c# - 如何为 UWP Windows 10 安装实体框架和 SQLite?
- javascript - 将 C# DateTime 推送到 JavaScript 数组
- electron - 无法运行 Electron 应用程序 - EINVAL:无效参数,lstat
- c - 打印给定文本文件中出现频率最高的单词,无法在 C 中按频率排序
- javascript - 正则表达式接受字符串前后的空格