bug-bash
[Top][All Lists]
Advanced

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

Re: [sorry for dups] Re: why difference between interactive+script doing


From: L A Walsh
Subject: Re: [sorry for dups] Re: why difference between interactive+script doing same thing?
Date: Mon, 27 Mar 2023 16:43:09 -0700
User-agent: Thunderbird

On 2023/03/27 13:28, Greg Wooledge wrote:
On Mon, Mar 27, 2023 at 01:05:33PM -0700, L A Walsh wrote:
filter_ssh() {
   ign0='ssh: connect to host \w+ port 22: Connection refused'
   ign1='(agent returned different signature type ssh-rsa)'
   ign2='(ssh_exchange_identification: read: Connection reset by peer)'
   ign3='(packet_write_wait: Connection to 192.168.3.12 port 22: Broken
pipe)'
   #ign="$ign1|$ign2|$ign3"
   ign="$ign1"
#    ssh -n -T "$user@$host" "$@" |& readarray output |&
#            grep -Pv "$ign" </dev/null | cat
   readarray output< <(ssh -n -T "$user@$host" "$@" 2>&1)
   echo "Read ${#output[@]} lines"
   for o in "${output[@]}"; do
       if [[ $o =~ $ign ]]; then continue; fi
       printf "%s" "$o"
   done
}

filter_ssh

You're calling filter_ssh with no arguments, but trying to use "$@"
inside it to generate the ssh command.
Isn't "$@" still valid? Originally I didn't have func-filterssh, it was inline.
I put it in a func to allow further debugging -- but you are right,
it's messed up.
You're also using dots inside a regex without backslashing them.  And
I'm not sure about the parentheses -- can't tell whether you meant those
to be literal or not.  They don't appear to serve any purpose if they're
not literal (there's no | inside them for example), but you didn't
backslash them either... very confusing.
Finally, using \w here is a libc extension and will only work on your
system, not necessarily other systems.  Just FYI.

As for the regex, I was originally trying to use grep -P to filter
the lines, again, as that didn't work it got migrated inside the function.

Note, this hacked version only searches for the 1st ignore msg, so the one
with the dots isn't included -- the parens were for grouping only, not capturing.

The '|' was to make a union of all the msgs, but it is commented out
to "simplify" things. (""?).  Also note, the \w was from attempt to use
grep-P

Will have to look over and see what simplifications are causing what --\
that's why I went with a separate test script -- apart from the script I had
tried to simplify -- since my problem occurs in the separate test script
apart from all the problems you point out in the original src script.

FWIW -- the multiple copies of that note that got sent to list -- try
to only look at latest DT-stamp, since as my post didn't appear, I examined
it and tried to fix some of the problems I saw...including hard coding the
command sent to ssh (so $@ isn't the problem).





reply via email to

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