AnswerBun.com

bash Noob: What's wrong with this line?

Unix & Linux Asked by OttoEisen on January 12, 2021

I’m trying to make a bash script written for BSD work on Linux, in case that’s relevant. Now I’m stumbling over this line:

json="$(sudo -u "${vpnUser}" -- curl --interface "${adaptorName}" --get --insecure --silent --show-error --fail --location --max-time "${curlMaxTime}" --data-urlencode "token=${authToken}" "https://${gatewayAddress}:19999/getSignature" | jq -Mre)"

I’ve echo’ed the values of the variables from the script and they look fine. Then I replaced the variables with the values. Then jq seems to complain about a syntax error (generic Usage: output) and curl, I assume, says (23) Failed writing body.
If a just run the command like sudo -u ... | jq -Mre it prints what looks like a JSON file.

Never mind! I got curious why the author would pipe the output through a parser which basically doesn’t do anything to the data, it only formats it into a more readable, multi-line output. And I assume that the multi-line format is the problem here? Removing everything after | helped.

Now another question: does anybody know if the original version is supposed to work with a BSD bash? Or should I tell the author (which states "…specifically in FreeBSD" in the comments) about this?

One Answer

Never mind! Had an Irish Coffee and looked into jq a bit, and got curious why the author would pipe the output through a parser which basically doesn't do anything to the data, it only formats it into a more readable, multi-line output. And I assume that the multi-line format is the problem here? Removing everything after | helped.

Answered by OttoEisen on January 12, 2021

Add your own answers!

Related Questions

How to validate a line if followed by a specifc line?

2  Asked on December 29, 2020 by user441539

     

LightDM: how to distinguish users with the same name?

2  Asked on December 29, 2020 by maddin25

 

Making bit identical ext2 filesystems

4  Asked on December 28, 2020 by jhufford

       

Which installed software packages use the most disk space on Debian?

9  Asked on December 28, 2020 by mirzhan-irkegulov

   

How to force ddclient to use only HTTPS?

0  Asked on December 28, 2020 by mountainx

   

How to execute a script after every systemd automount?

1  Asked on December 27, 2020 by john-wh-smith

     

How to detect and clean up junk journal files?

1  Asked on December 27, 2020 by reinierpost

   

ARM LXC Container template

2  Asked on December 27, 2020 by bulkmoustache

         

Updating kernel: vmlinuz in /boot not being created by DNF

4  Asked on December 26, 2020 by big-millz

       

Samba shared folder with setgid problem

1  Asked on December 24, 2020 by alex-forencich

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir