0
I have a bash script which sends a couple of notifications to Slack via CURL and spawns an expect script.
When I run the script via . scriptName.sh
it works fine, but when I run it by typing ./scriptName.sh
the CURL portions fail with the error message:
protocol $https not supported or disabled in libcurl
Here's the basic file:
curl --data "building Dev" $"https://domain.slack.com/services/hooks/slackbot?token=yourTokenHere&channel=%23yourChannelHere"
expect script.exp
curl --data "Dev built" $"https://domain.slack.com/services/hooks/slackbot?token=yourTokenHere&channel=%23yourChannelHere"
2Is your script executable? If not run
chmod a+x scriptName.sh
. The.
command requires only that a script be readable. – AFH – 2015-10-19T16:04:22.243@AFH Duh I feel like a moron. I actually thought of that, but my coworker said he did that already :/ Thanks!!! – General_Twyckenham – 2015-10-19T16:05:45.857
Did making the script executable fix anything? That's surprising to me, as if the script wasn't executable, bash wouldn't have run it so it wouldn't even get to the curl. My guess is that the https environment variable hasn't been exported. . scriptName.sh runs the script in the same shell, so the script sees all environment variables. ./scriptName.sh runs the script in a subshell, so it only sees exported environment variables. Try
export https;./scriptName.sh
and see if that changes anything. – blm – 2015-10-19T16:33:21.887Why is there a
$
before the URL? In bash, this invokes string localization; in other shells,... who knows? Speaking of which, your script really should start with a shebang line, like#!/bin/bash
. – Gordon Davisson – 2015-10-20T03:19:54.793@blm Thanks for the advice. According to AFH's earlier comment, the
.
seems to execute the file even if it's only readable. Making the script executable did fix my issue, but I would have tried your suggestions had it not worked. – General_Twyckenham – 2015-10-20T14:49:22.577@GordonDavisson I will add the shebang. I don't remember where the
$
came from, possibly from the Slack API docs, but it seems to work properly when the file is permissioned properly – General_Twyckenham – 2015-10-20T14:50:40.490