Using Commands in Scripts

    Redirected from Documentation/How-tos/Making Commands Non-Interactive

    GROMACS programs are typically interactive, with selection of index groups made after the program is started.

    There are two options to enable the programs to be executed non-interactively in shell scripts (using the example of g_rms):


    Command Line

    echo 3 3 | g_rms -flags


    Within Script

    There is no fundamental difference between a script and the command line (above) but for extensive user input the following syntax may be used as well (note that this is csh / tcsh notation, bash fanatics might want to add the bash equivalent here).

    g_rms -flags <<EOF

    Or by having the index choices contained within a text file:

    g_rms -flags < choices.txt

    Where choices.txt contains:



    Using Group Names

    As sometimes the numbers of certain choices may vary from case to case, in Gromacs 3.3.1 and later it is possible to pass the explicit names to the tools.

    g_energy -f ener.edr << EOF

    The best fit will be used, if you select e.g. Pres the first term starting with Pres will be used.


    Complex cases

    Should you encounter a more complex need, the expect tool automates human-script interaction in a programmatic fashion.

    Page last modified 13:24, 3 Feb 2012 by mabraham