简体   繁体   中英

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:

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).

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".

How can I fix this?

You need to convert those lines in the script into input to orca_plot. Use a 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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