[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sorry for dups] Re: why difference between interactive+script doing
From: |
Greg Wooledge |
Subject: |
Re: [sorry for dups] Re: why difference between interactive+script doing same thing? |
Date: |
Mon, 27 Mar 2023 16:28:34 -0400 |
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.
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.
why difference between interactive+script doing same thing?, L A Walsh, 2023/03/27