Unix & Linux Asked by ELU on December 4, 2020
I have a script with the following code line:
currentTenantId="$(az account show --query tenantId | jq -r 2>/dev/null)"
This line gives me the following error message:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
I broke it down and tried this:
az account show --query tenantId #OK - no errors
az account show --query tenantId | jq -r 2>/dev/null #OK - no errors
"$(az account show --query tenantId | jq -r 2>/dev/null)" #NOT OK - same error as mentioned above
Additional info:
When i run just this (and not putting the result into a variable):
"$(az account show --query tenantId | jq -r 2>/dev/null)"
I get:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
Command '' not found, but can be installed with:
sudo apt install libpam-mount
sudo apt install openssh-server
sudo apt install openvswitch-common
sudo apt install openvswitch-switch
sudo apt install php-common
sudo apt install bpfcc-tools
sudo apt install burp
sudo apt install cryptmount
sudo apt install dolphin-emu
sudo apt install mailutils-mh
sudo apt install mmh
sudo apt install nmh
This script is used on several other clients and works on other clients.
So I’m not looking to do any changes in the script, but since it works on other clients I think it should be something on my client that’s missing.
Can any of you lead me in any direction to solve this?
I’m running Ubuntu 18.04.
When I run:
currentTenantId="$(az account show --query tenantId | jq -r)"
I get:
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
Usage: jq [options] <jq filter> [file...]
jq is a tool for processing JSON inputs, applying the
given filter to its JSON text inputs and producing the
filter's results as JSON on standard output.
The simplest filter is ., which is the identity filter,
copying jq's input to its output unmodified (except for
formatting).
For more advanced filters see the jq(1) manpage ("man jq")
and/or https://stedolan.github.io/jq
Some of the options include:
-c compact instead of pretty-printed output;
-n use `null` as the single input value;
-e set the exit status code based on the output;
-s read (slurp) all inputs into an array; apply filter to it;
-r output raw strings, not JSON texts;
-R read raw strings, not JSON texts;
-C colorize JSON;
-M monochrome (don't colorize JSON);
-S sort keys of objects on output;
--tab use tabs for indentation;
--arg a v set variable $a to value <v>;
--argjson a v set variable $a to JSON value <v>;
--slurpfile a f set variable $a to an array of JSON texts read from <f>;
See the manpage for more options.
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
Solution: Turned out that the command was wrong. This is how it should look like:
currentTenantId="$(az account show --query tenantId 2>/dev/null | jq -r .)"
Correct answer by ELU on December 4, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP