linux系统交互式脚本,linux - 有bash脚本回答交互式提示

在我的情况下,我需要回答一些没有Y或N但有文字或空白的问题。 我发现在我的情况下执行此操作的最佳方法是创建一个shellscript文件。 在我的情况下,我称之为autocomplete.sh

我需要为一个学说模式导出器回答一些问题,所以我的文件看起来像这样。

- 这只是一个例子 -

php vendor/bin/mysql-workbench-schema-export mysqlworkbenchfile.mwb ./doctrine << EOF

`#Export to Doctrine Annotation Format` 1

`#Would you like to change the setup configuration before exporting` y

`#Log to console` y

`#Log file` testing.log

`#Filename [%entity%.%extension%]`

`#Indentation [4]`

`#Use tabs [no]`

`#Eol delimeter (win, unix) [win]`

`#Backup existing file [yes]`

`#Add generator info as comment [yes]`

`#Skip plural name checking [no]`

`#Use logged storage [no]`

`#Sort tables and views [yes]`

`#Export only table categorized []`

`#Enhance many to many detection [yes]`

`#Skip many to many tables [yes]`

`#Bundle namespace []`

`#Entity namespace []`

`#Repository namespace []`

`#Use automatic repository [yes]`

`#Skip column with relation [no]`

`#Related var name format [%name%%related%]`

`#Nullable attribute (auto, always) [auto]`

`#Generated value strategy (auto, identity, sequence, table, none) [auto]`

`#Default cascade (persist, remove, detach, merge, all, refresh, ) [no]`

`#Use annotation prefix [ORM\]`

`#Skip getter and setter [no]`

`#Generate entity serialization [yes]`

`#Generate extendable entity [no]` y

`#Quote identifier strategy (auto, always, none) [auto]`

`#Extends class []`

`#Property typehint [no]`

EOF

我喜欢这个策略的是你可以评论你的答案是什么,并使用EOF一个空行就是那个(默认答案)。 顺便说一下,这个导出工具有自己的JSON对应方式来回答这些问题,但是在我这样做之后我想出了这个=)。

运行脚本只需在您想要的目录中,并在终端中运行'sh autocomplete.sh'。

简而言之,通过将<< EOL和EOF与Return Lines结合使用,您可以根据需要回答每个提示问题。 每个新行都是一个新答案。

我的例子只是展示了如何使用`字符进行注释,以便你记住每个步骤是什么。

注意这种方法的另一个优点是你可以用更多的答案来回答Y或N ...实际上你可以用空白来回答!

希望这有助于某人。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值