[英]Getting bash script to enter in numbers in an 'interactive mode' prompt
There is an interactive mode that can be turned on in the program ORCA I am using by typing in the following command: 通过使用以下命令,可以在正在使用的ORCA程序中打开一种交互模式:
module load openmpi/2.1.2 orca/orca_4_0_1_2_linux_x86-64_openmpi202
Once this is enabled, I can give it a command to plot a graph with: 启用此功能后,我可以为其命令绘制图形:
orca_plot IPC_CAS1_restart2f-NEVPT2.gbw -i
The program then offers me choices, which I can choose from by entering a number into the prompt. 然后,程序为我提供了选择,可以通过在提示中输入数字来选择。 I wish to automate this process by having a bash script that enters a specific sequence of numbers for me (ie 1, then 3, then 2, then 7 for example). 我希望通过让bash脚本为我输入一个特定的数字序列(例如1、3、2、7)来使该过程自动化。
My script looks like the following, 我的脚本如下所示,
#!/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
I get the messages "line 4: 1: command not found", "line 5: 3: "command not found", "line 7: 2: command not found", "line 8: 7: command not found". 我收到以下消息:“第4行:1:找不到命令”,“第5行:3:“找不到命令”,“第7行:2:没有找到命令”,“第8:7:未找到命令”。
How can I fix this? 我怎样才能解决这个问题?
You need to convert those lines in the script into input to orca_plot. 您需要将脚本中的这些行转换为orca_plot的输入。 Use a heredoc: 使用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.