繁体   English   中英

获取bash脚本以在“交互模式”提示下输入数字

[英]Getting bash script to enter in numbers in an 'interactive mode' prompt

通过使用以下命令,可以在正在使用的ORCA程序中打开一种交互模式:

module load  openmpi/2.1.2 orca/orca_4_0_1_2_linux_x86-64_openmpi202

启用此功能后,我可以为其命令绘制图形:

orca_plot IPC_CAS1_restart2f-NEVPT2.gbw -i

然后,程序为我提供了选择,可以通过在提示中输入数字来选择。 我希望通过让bash脚本为我输入一个特定的数字序列(例如1、3、2、7)来使该过程自动化。

我的脚本如下所示,

#!/bin/bash 
module load  openmpi/2.1.2 orca/orca_4_0_1_2_linux_x86-64_openmpi202
orca_plot IPC_CAS1_restart2f-NEVPT2.gbw -i
1
3
2 
7 

我收到以下消息:“第4行:1:找不到命令”,“第5行:3:“找不到命令”,“第7行:2:没有找到命令”,“第8:7:未找到命令”。

我怎样才能解决这个问题?

您需要将脚本中的这些行转换为orca_plot的输入。 使用heredoc:

#!/bin/bash 
module load  openmpi/2.1.2 orca/orca_4_0_1_2_linux_x86-64_openmpi202
orca_plot IPC_CAS1_restart2f-NEVPT2.gbw -i << EOF
1
3
2 
7 
EOF

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM