bug-bash
[Top][All Lists]
Advanced

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

why difference between interactive+script doing same thing?


From: L A Walsh
Subject: why difference between interactive+script doing same thing?
Date: Mon, 27 Mar 2023 12:24:35 -0700
User-agent: Thunderbird

Don't know that this is a bug -- there is likely some reason why there's
a  difference in interactive vs. script execution. Certainly is annoying!



I'm trying to develop a script to help me run commands on a remote
system. Seems obvious -- it is ssh based, but for me ssh generates
1 warning message 'reliably' that I want to filter out.

Thus the infrastructure.

Thing is, -- the code to read output from ssh, stops after the
error message if the script (or ssh|filter) is running automatically
(in a script).  When I run the same commands interactively, I get the
full output.

The error that gets filtered (in an array):

declare -a output=([0]=$'warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)\r\n')

The salient part is

   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

Interactively, I get the error followed by the expected output, but in script,
I get 1 line -- the error message.  Example:

interactive:

readarray out< <(ssh -n -T "$user@$host" 'printf "1\n2\n3\n4\n5\n"' 2>&1); printf "%s" "${out[@]}" warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
1
2
3
4
5

In script:

on_host athenae 'printf "1\n2\n3\n4\n5\n"' Using host athenae
103: host athenae, up
Read 1 lines
declare -a output=([0]=$'warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)\r\n')

(but no 1,2,3,4,5 output)

Why would this work interactively, but not in script?

I can post the entire script, but didn't want to go overboard if possible.

Thanks.















reply via email to

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