Issue with streaming input data with curl into a Unix pipe [duplicate] - bash

This question already has answers here:
Bash if or statement, command not found
(2 answers)
Why do I get "command not found" with the NOT operator in a Bash conditional?
(3 answers)
Using jq to parse JSON in launchd
(2 answers)
In Jenkins while executing some code its throwing an error "jq command not found"
(1 answer)
Closed 3 years ago.
I am having problems streaming data into a unix pipe.
Here is my command:
curl http://stream.meetup.com/2/rsvps |  jq '.event.event_name'
Here is the error I get:
zsh: command not found:  jq
Can someone please help?
edit: jq is installed properly as shown by:
~ which jq
/usr/local/bin/jq

Related

What shell uses cron on Ubuntu server? [duplicate]

This question already has answers here:
Difference between sh and Bash
(11 answers)
How to run a bash script via Cron
(3 answers)
Closed 7 months ago.
I made a bash script for Ubuntu server with C-style if-then clause if (( $var = 6 )). It works perfectly from command line, but stuck when I made cronjob for this script. I changed it to if [ $var -gt 6 ] and then cron began to work. I assume that cron uses different shell, but what type and what other differences with bash?

Golang - how to spawn a process that takes a glob pattern as one of its command-line arguments? [duplicate]

This question already has answers here:
golang failed exec command that works in terminal
(1 answer)
How to pipe several commands in Go?
(8 answers)
Golang exec command chmod returning error
(2 answers)
Closed last year.
From my bash shell, I am able to run this following command successfully - scp <local-folder>/* <user>#<remote-host>:/var/tmp. All files in my <local-folder> are copied onto the remote location.
Now I am trying to run the above same command from my Go program, with exec.Command() but scp complains of "no such file / directory - <local-folder>/*' - the '*' is literally taken as a filename. I want to replicate the same behaviour of scp I get when I run it from my Bash shell. Here is the code snippet I am using:
pushCmd := exec.Command("scp", "<local-folder>/*", "<user>#<remote-host>:/var/tmp")
pushCmdOutput, err = pushCmd.CombinedOutput()
fmt.Fprintln(os.Stderr, string(pushCmdOutput))
Thanks in advance.

What does "not foundh" mean from a .sh script? [duplicate]

This question already has answers here:
Error With Bash Script [duplicate]
(5 answers)
Are shell scripts sensitive to encoding and line endings?
(14 answers)
Difference between sh and Bash
(11 answers)
Closed 3 years ago.
I'm trying to run a script called autogen.sh on my Ubuntu system (WSL) which begins with
#!/bin/sh
set -xe
type autoreconf > /dev/null || exit 1
type pkg-config > /dev/null || exit 1
You can get the full script by running git clone https://github.com/universal-ctags/ctags.git
And it gives me
mark#surface-19:~/ctags$ ./autogen.sh
: not foundh: 2: ./autogen.sh:
./autogen.sh: 3: set: Illegal option -
I'm having a hard time understanding the error message "not foundh". It seems to be a typo of "not found" but what exactly is not being found?

rsync remote to local - Unexpected remote arg [duplicate]

This question already has answers here:
How to execute a bash command stored as a string with quotes and asterisk [duplicate]
(5 answers)
Why does shell ignore quoting characters in arguments passed to it through variables? [duplicate]
(3 answers)
Closed 4 years ago.
I'm trying to assemble an rsync command in a bash variable and then execute it.
It looks something like this:
CMD="$RSYNC -a $REMOTE $LOCAL $LINK_DEST"
It gets executed like this
RSYNC_RESULT=$($CMD)
This works fine until I try to add add --rsync-path="sudo /usr/local/bin/rsync" to the mix (so that rsync runs as root on the remote).
RSYNC_PATH='--rsync-path="sudo /usr/local/bin/rsync"'
CMD="$RSYNC -a $RSYNC_PATH $REMOTE $LOCAL $LINK_DEST"
Now I get an error
Unexpected remote arg: user#remote.local:/Users/user/files/
rsync error: syntax or usage error (code 1) at main.c(1343) [sender=3.1.2]
I'm fairly certain it's connected to the quoting in the $RSYNC_PATH var and/or the $($CMD) bit, because I can paste the resulting command into a shell and it runs successfully.
Any ideas what I can do to make this work?

Get running time of script in variable (bash) [duplicate]

This question already has answers here:
get values from 'time' command via bash script [duplicate]
(4 answers)
How to store a substring of the output of "time" function in bash script
(3 answers)
Closed 5 years ago.
I'm looking to capture the execution time of an rsync transfer and then store that time in a variable for a later step in my bash script.
I have tried the following:
ELAPSED=$(time $(rsync -azh source/ dest &> /dev/null)) to no avail. The elapsed time is printed to the screen, but it is not saved in the ELAPSED variable.
I have also tried: ELAPSED=$(/usr/bin/time sh -c "rsync -azh source/ dest &> /dev/null") but this actually takes the sh output and stores that output into the variable, not the time.
Any insights on a better method or corrections to my attempts are appreciated in advance!

Resources