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: Fri, 24 Mar 2023 15:53:07 -0700
User-agent: Thunderbird

Don't know that this is a bug -- there maybe some reason why there's
a  difference in interactive vs. script execution...certainly isn't helpful
in trying to develop a script though.


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]