1

I'm new in Linux and I'm trying to make my first bash script to improve my work at college. Im working with a software called GROMACS and I'm trying to make a script to perfom a bunch of codes at the same time, but in one of the lines I need needs an input (number) from the keyboard. What can I do to make this script work?

Here are my lines:

!#/bin/bash
gmx pdb2gmx -f protein_name.pdb -o protein_name_processed.gro -water spce

And that last line needs the keyboard input (number 15)

Thanks for your help.

marked as duplicate by jasonwryan, sam, John WH Smith, Kusalananda, Archemar Jul 19 '16 at 8:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Unrelated to your question: You will need to swap the ! and # so your first line reads #!/bin/bash. – Timothy Martin Jul 18 '16 at 22:09
3

I think this is some sort of a scientific software and it should be able to accep input from the pipe. You can try:

echo "My input string" | gmx pdb2gmx -f protein_name.pdb -o protein_name_processed.gro -water spce

if you have spaces in your string, the double quotes are not optional. If it is a single word input, you can skip them.

  • Thank you very much MelBurslan for your help. It works. I really appreciate it. – Felipe Rojas Jul 18 '16 at 22:10
  • if this answer solved your problem, you should Accept it and mark the question as "answered" by clicking on the big tick to the left. – cas Jul 19 '16 at 14:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.