On 28/08/2014 at 00:38, Ole Tange <o...@tange.dk> wrote: > You should test that it works with all the supported styles of > sshlogins. From the man page:
Hi, I made the script more robust and it now seems to support all the styles of sshlogins: ################################################################################ cp original.slf updated.slf while [ 1 ] ; do nice parallel --timeout 1000% --nonall -j0 -k --slf original.slf --tag echo | \ sed -e 's#\t$##' -e '#\t#d' | \ nice parallel -k "sed -n 's#^\([[:digit:]]\+/\)\{0,1\}{}\$#&#p' original.slf | head -n 1" > tmp.slf if ! cmp -s tmp.slf updated.slf; then mv tmp.slf updated.slf fi sleep 10 done & parallel --slf updated.slf ... ################################################################################ The command which, given a sshlogin string, recovers the full entry from the original slf file (original.slf) is: "sed -n 's#^\([[:digit:]]\+/\)\{0,1\}{}\$#&#p' original.slf | head -n 1" Basically, it assembles a matching pattern that begins with the optional specification of the number of slots (will match e.g. "16/" or none): ^\([[:digit:]]\+/\)\{0,1\} then it appends the sshlogin string at hand until the end of the line: {}\$ finally, the corresponding matched pattern (full entry) is printed by #&#p ########## There are two minor limitations, though: 1) If the original.slf contains duplicate entries differing only by the specification of the number of slots, such as: server.net 8/server.net only the first one will be picked (this is what 'head -n 1' does). 2) I'd like to prevent the replacement {} from being quoted by GNU Parallel, but it insists on converting something like: ssh -p 2222 server.domain.net into ssh\ -p\ 2222\ server.domain.net This by itself doesn't seem to be a problem within sed. The problem is that I cannot quote the dots in server.domain.net (making it server\.domain\.net, turning off their special meaning within sed) because GNU Parallel overrides any attempt of doing so. For instance, the following would work: parallel --rpl '{quote} s#\.#\\.#g' -k "sed -n 's#^\([[:digit:]]\+/\)\{0,1\}{quote}\$#&#p' original.slf | head -n 1" but only if replace this line: my $cmdstring = $self->replace_placeholders($self->{'command'},$Global::quoting,$quote_arg); by my $cmdstring = $self->replace_placeholders($self->{'command'},$Global::quoting,0); in GNU Parallel's source code. Am I missing something? -- Douglas A. Augusto