0

I'm trying to write a shellscript using azure cli, az cli gives warning such as one pasted below,

Command group 'backup' is in preview. It may be changed/removed in a future release.

I have tried to use 2 and 1 redirection ( 2> /dev/null & 1> /dev/null & > /dev/null 2>&1) but it still shows warning when az cli commmand is executed.

Edit here

I have tried the following ways of redirection

az backup arguments... 1> /dev/null - just gave it a try out of curiosity but this suppresses the output and shows warning message.

az backup arguments... 2> /dev/null - it gives both warning message and desired output

az backup arguments... > /dev/null 2>&1 - does not show desired output but shows warning message.

I only want output while warning or error message should be ignored/suppressed.

I'm using -

az backup container list --backup-management-type AzureIaasVM --resource-group ${RESOURCE_GROUP} --vault-name ${VAULT_NAME} --subscription ${SUBSCRIPTION} --query "[?contains(name, '${VM_NAME}')].[name]" -o tsv

Any help or suggestion would be greatly appreciated. Thanks

Community
  • 1
  • 1
  • Try: `az ....... >/dev/null 2>&1` – Jetchisel Apr 28 '20 at 03:09
  • Putting in the `&`s on their own defeats your efforts. A `&` is a command separator. In `foo & bar`, `foo` and `bar` are two different commands. Thus, `ar 2>/dev/null & 1>/dev/null` puts the `1>/dev/null` in a separate command from `ar`, so only the first redirection takes effect. – Charles Duffy Apr 28 '20 at 03:10
  • i want the output while any error or warning should be suppressed. If i do `>/dev/null 2>&1` this won't give me output or result... even with this redirection, warning still shows up on the terminal. – opensource junkie Apr 28 '20 at 04:08
  • @CharlesDuffy - sorry for confusion i'm not putting all of this at once ( 2> /dev/null & 1> /dev/null & > /dev/null 2>&1), i have tried it one by one `az ..... 1> /dev/null` then `az ..... 2> /dev/null` and finally `az ....... > /dev/null 2>&1` – opensource junkie Apr 28 '20 at 04:11
  • In that case, I would guess your program is communicating directly with the TTY. We have existing Q&A telling you how to deal with that -- the `unbuffer` tool from the `expect` suite, for example. – Charles Duffy Apr 28 '20 at 05:14

0 Answers0