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?
Related
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?
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.
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
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?
This question already has answers here:
Why does "local" sweep the return code of a command?
(2 answers)
Why is bash errexit not behaving as expected in function calls?
(4 answers)
Closed 4 years ago.
I want to know how best to exit a script when an error occurs within a sub-command - specifically, in an assignment (i.e., of the form MYVAR="$(...)").
The minimal example of my problem is the following bash script.
#!/bin/bash
set -e
fail() {
echo "Some error" >&2
exit 1
}
main() {
local my_val="$(fail)"
echo 'Success!'
}
main
This will output the following:
Some error
Success!
What I am trying to figure out is how best to detect and handle the failure which occurs so that the Success stage is never reached.