parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prefix each line with "input line"


From: Manuel Landesfeind
Subject: Re: Prefix each line with "input line"
Date: Sun, 02 Oct 2011 12:27:18 +0200
User-agent: Roundcube Webmail/0.5

Hi,

I like to "+1" because this may also be very helpful if a command failed only on a special node. This way one could be able to get that server:

Example:

$ parallel -S "$SERVER_LIST' ::: '/path/to/unknown_command --version'

Regards,
Manuel

---
www.landesfeind.de

On Sun, 2 Oct 2011 12:15:28 +0200 (CEST), Hans Schou wrote:
Hi

I have a number of servers and sometimes I want to check a setting on
all of them. Like "what is the default search domain".

For convenience I have all the server names in the environment:
 export srv_all="example.org example.com"
(could be in a file, but environment is always at hand)

Then I get the answer by running:
 parallel ssh {} "grep search /etc/resolv.conf" ::: $srv_all
and the output:
 search example.org
 search example.xxx

In the case above I really missing the hostname for the line with
"example.xxx" as this is wrong.

To get the hostname (input line) prefixed on each line I have to
write a bit more:

parallel echo -n {}: \; ssh {} "grep search /etc/resolv.conf" ::: $srv_all

Then the output become:
 example.org:search example.org
 example.com:search example.xxx
and then I go to example.com and fix the problem.

One problem is that when get more lines than one, e.g. there is more
lines which matches my grep, like 'nameserver', then only the first
line got the prefix.

The command for that is:
 parallel ssh {} grep nameserver /etc/resolv.conf \| sed -e s/^/{}:/
::: $srv_all

...but "\| sed -e s/^/{}:/" is not that nice to read.

Second is that it would be nice if "echo -n {}: \;" could be a
one-character-option.

/hans




reply via email to

[Prev in Thread] Current Thread [Next in Thread]