Getting "Scheme Missing" Error with Wget

I wrote a little script that grabs a random wallpaper from the Desktoppr API and changes my desktop wallpaper to it:

#!/bin/bash
url=$(curl '(shuf -i 1-1000 -n 1) | jq ".response[].image.url" | sed $(shuf -i 1-20 -n 1)'!d') &&
wget "$url"

When I run the script, the final wget command fails with the error:

"": Scheme missing.

When I put the URL directly into the wget command, like so:

wget ""

... the command executes correctly and downloads the image, meaning that the error occurs because of some problem in the variable.

I think this might have something to do with the jq library that I am using to parse the JSON response from the Desktoprr API.

1 Answer

You need to remove the double quotes surrounding the URL, for example by using the -r option to jq:

url=$(curl '(shuf -i 1-1000 -n 1) | jq -r ".response[].image.url" | sed $(shuf -i 1-20 -n 1)'!d')

Currently the command actually results in

wget "\"""
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest