Sponsored Content
Top Forums Shell Programming and Scripting Redirect string from bash stderr to user stdin Post 302998284 by fredestet on Monday 29th of May 2017 05:45:29 AM
Old 05-29-2017
OK, I'm convinced and will try to explain in more detail. The command in question is called gmx genion from the Gromacs package for molecular dynamics simulations. When executing it in a bash terminal, it prints (using stderr) something like
Code:
Select a continuous group of solvent molecules
Group     0 (         System) has 51133 elements
Group     1 (        Protein) has  3961 elements
Group     2 (      Protein-H) has  1951 elements
Group     3 (        C-alpha) has   244 elements
Group     4 (       Backbone) has   732 elements
Group     5 (      MainChain) has   977 elements
Group     6 (   MainChain+Cb) has  1211 elements
Group     7 (    MainChain+H) has  1215 elements
Group     8 (      SideChain) has  2746 elements
Group     9 (    SideChain-H) has   974 elements
Group    10 (    Prot-Masses) has  3961 elements
Group    11 (    non-Protein) has 47172 elements
Group    12 (          Other) has    44 elements
Group    13 (            UNK) has    44 elements
Group    14 (          Water) has 47128 elements
Group    15 (            SOL) has 47128 elements
Group    16 (      non-Water) has  4005 elements
Select a group:

expecting me to type one of the numbers and hit ENTER. I would always choose the number associated with the group SOL, hence 15 in this particular case. However, this number can vary and I want to automate this step in a bash script where, currently, I execute gmx genion twice:
Code:
groupselect=$(echo "" | gmx genion -s $manyArgs 2>&1 > /dev/null | awk '/ SOL\) has.*elements$/ {print $2}')
echo $groupselect | gmx genion -s $manyArgs 2>&1

The first line stores the string "15" in the variable called $groupselect whereas the second call executes the tool as desired with the content of $groupselect as input. Now, I would like to avoid one of the two calls to gmx genion. Is there a way to get this job done with a single call of gmx genion?

Thanks so far for your efforts!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirect stderr to dev/null in bash env.

Working in a bash environment, in the following example, how do I direct the error message that putting in an invalid flag (-j for example) would normally produce to dev/null? while getopts "abcd" opt do case "$opt" in i) a etc ;; r) b etc ;; f) c etc ;; v) d... (7 Replies)
Discussion started by: Sniper Pixie
7 Replies

2. Shell Programming and Scripting

redirect STDIN

can you redirect STDIN with command arguments? I have tried this approach: # ./script -option <argument1> <argument2> 0<$2 # $2: ambiguous redirect Is this possible? (4 Replies)
Discussion started by: prkfriryce
4 Replies

3. Shell Programming and Scripting

can't redirect stderr in bash

Consider: #!/bin/sh #this is a shell script in sh (bourne) grep missingfile 2>errout.txt It works from the command line, but keeps producing errors from the script. So how do I redirect in a bash shell...or bourne? (3 Replies)
Discussion started by: lumix
3 Replies

4. Programming

Redirect stdin and out to sockets

For windows was pretty simple to redirect the std in a and out of a child process for "cmd.exe " command prompt terminal to a socket using connected pipes passed to a new process in the STARTUPINFO structure. BOOL b = ::CreatePipe((LPHANDLE)h_stdInRead,(LPHANDLE)hsdtInWriteTmp, &SecAttrib,... (1 Reply)
Discussion started by: gyula
1 Replies

5. Shell Programming and Scripting

inline redirect stdin

Hi: I have the next script on ksh #!/usr/bin/ksh cd $FUENTES qdesign <<-! \$/opt/cognos/ph843e/bin/qtp <<-! \$/opt/cognos/ph843e/bin/quiz <<-! ! ! ! This script is very simple, i want to nest three process quiz into qtp, and this into qdesign. When I run it , i receive the... (5 Replies)
Discussion started by: ct2marer
5 Replies

6. UNIX for Advanced & Expert Users

inline redirect stdin

Hi: I have the next script on ksh #!/usr/bin/ksh cd $FUENTES qdesign <<-! \$/opt/cognos/ph843e/bin/qtp <<-! \$/opt/cognos/ph843e/bin/quiz <<-! ! ! ! This script is very simple, i want to nest three process quiz into qtp, and this into qdesign. When I run it , i receive the next... (2 Replies)
Discussion started by: ct2marer
2 Replies

7. Shell Programming and Scripting

Cannot redirect to STDIN in a shell script

I am unable to use STDIn redirection with < (commands) When I do the following, both approaches work and give the same results: 1. $ printf "aaa\nbbb\n" > file1 $ printf "111\n222\n" > file2 $ cat file1 file2 aaa bbb 111 2222. $ cat <(printf "aaa\nbbb\n") <(printf "111\n222\n") aaa... (8 Replies)
Discussion started by: metaltree
8 Replies

8. Shell Programming and Scripting

Redirect String to STDIN

Looking for the proper way to bring a string into the stdin. I have a string that I would like to grep and awk. Each have to be run separately, not piped together. So far, the only way I could figure out how is to echo the string and pipe it: echo 'This is my string' | grep my (3 Replies)
Discussion started by: Panman82
3 Replies

9. UNIX for Advanced & Expert Users

How to set font color for STDIN,STDOUT and STDERR?

I want to differentiate the STDOUT and STDERR messages in my terminal . If a script or command is printing a message in terminal I want to differentiate by colors, Is it possible ? Example: $date Wed Jul 27 12:36:50 IST 2011 $datee bash: datee: command not found $alias ls alias... (2 Replies)
Discussion started by: ungalnanban
2 Replies

10. Shell Programming and Scripting

Redirect stdout/stderr, except e.g. "STRING"

Hi, I'm running a program (Python) whose output I would like to redirect to a log. But the program calls a library (that I cannot change), which outputs all sorts of useless information. I would like to redirect all output from my Python program into this log, except output that matches the... (7 Replies)
Discussion started by: rswindle
7 Replies
RT::Client::REST::Group(3pm)				User Contributed Perl Documentation			      RT::Client::REST::Group(3pm)

NAME
RT::Client::REST::Group -- group object representation. SYNOPSIS
my $rt = RT::Client::REST->new(server => $ENV{RTSERVER}); my $group = RT::Client::REST::Group->new( rt => $rt, id => $id, )->retrieve; DESCRIPTION
RT::Client::REST::Group is based on RT::Client::REST::Object. The representation allows one to retrieve, edit, and create groups in RT. Note: RT currently does not allow REST client to search groups. ATTRIBUTES
id For retrieval, you can specify either the numeric ID of the group or his group name. After the retrieval, however, this attribute will be set to the numeric id. name Name of the group description Description members List of the members of this group. DB METHODS
For full explanation of these, please see "DB METHODS" in RT::Client::REST::Object documentation. retrieve Retrieve RT group from database. store Create or update the group. search Currently RT does not allow REST clients to search groups. INTERNAL METHODS
rt_type Returns 'group'. SEE ALSO
RT::Client::REST, RT::Client::REST::Object, RT::Client::REST::SearchResult. AUTHOR
Miquel Ruiz <mruiz@cpan.org> LICENSE
Perl license with the exception of RT::Client::REST, which is GPLed. perl v5.14.2 2012-01-20 RT::Client::REST::Group(3pm)
All times are GMT -4. The time now is 11:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy