On Thu, Nov 18, 2021 at 06:12:12PM -0700, Grant Taylor via COFF wrote:
I've been told that PowerShell and / or the
commands run therefrom actually
pass structural data that is easy to query /if/ you know how to do so. It's
this structure vs free form textual output that is common in Unix shells
that make the biggest difference. Think XML markup vs an unstructured text
file. (Though you don't actually see the structure scaffolding.)
So I take it you can do something a bit more civilized than this in Powershell?
run_gcloud compute instances describe --zone "$z" "$i"
--format=json > "$inst_info"
kver=$(jq < "$inst_info" 2> /dev/null
'.metadata.items[] | select(.key == "kernel_version") | .value' | \
sed -e 's/^"//' -e 's/"$//' -e 's/^Linux
xfstests-[0-9A-Za-z-]* //' \
-e 's/ .*//')
gce_status=$(jq < "$inst_info" .status | sed -e 's/^"//'
-e 's/"$//')
status=$(jq < "$inst_info" 2> /dev/null \
'.metadata.items[] | select(.key == "status") | .value' | \
sed -e 's/^"//' -e 's/"$//')
ip=$(jq < "$inst_info" 2> /dev/null \
'.networkInterfaces[] | .accessConfigs[] | select(.name == "external-nat")
| .natIP' | \
sed -e 's/^"//' -e 's/"$//')
echo "$i $ip - $kver - $status - $gce_status"
I probably should rewrite the 3500-4000 or so lines of bash script
which is gce-xfstests in Python or Go, but the script has been growing
over the years, and in many ways shell scripting is one of the faster
languages for prototyping new functionality, at least for me, than
Python. Plus which, bash doesn't do forced march upgrades like Python
does....
- Ted