LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-15-2017, 06:19 PM   #1
L_Carver
Member
 
Registered: Sep 2016
Location: Webster MA USA
Posts: 241

Rep: Reputation: Disabled
Question bash: curl can't find URL value in variable


The above is pretty much all that is wrong with the following script:
Code:
#!/bin/bash
notee="Downloaded with GNU cUrl 7.47.0."
echo "Please enter the name of the picture file to use."
read -er newname
echo "Please enter (or paste) the URL on which the file is located."
read -er fg
echo "$fg"
curl -k --progress-bar	 -O -R $fg
	date0=$(date "+%A %B %d, %Y")
	drape1=${fg##*/}
	echo "$drape1"
	exiv2 -M"set Xmp.xmpRights.WebStatement $1" --keep "$drape1"
	exiv2 -M"set Exif.Image.DocumentName $1" --keep "$drape1"
	exiftool -fast5 -overwrite_original_in_place -P -q -Instructions="Downloaded $date0" -SpecialInstructions="Downloaded $date0" "$drape1" 2>/dev/null
	exiftool -fast5 -overwrite_original_in_place -P -q -XMP-acdsee:Notes="$notee" -IPTC:EditStatus="$notee" "$drape1" 2>/dev/null
	echo "$newname"
	mv "$drape1" "$newname"
	echo "File $drape1 is now called $newname."
shellcheck finds this error:
Code:
In /home/steve/bin/jericurl line 9:
curl -k --progress-bar   -O -R $fg
                               ^-- SC2086: Double quote to prevent globbing and word splitting.
Copied and pasted to stdout, a value assigned to the variable works without the quotes on either side, and gives the curl: no URL specified! error with them.

The problem is likely something quite simple, but I can't puzzle out what it might be.

Carver
 
Old 12-15-2017, 06:50 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,363

Rep: Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006Reputation: 2006
What error do you get when you run the script as posted?
What happens when you run the script with double quotes around the $fg on the curl -k line? With single quotes?
What is the URL you're using? Does it contain any characters that the shell is going to want to glob? (*,?,etc.)
 
Old 12-26-2017, 10:30 AM   #3
L_Carver
Member
 
Registered: Sep 2016
Location: Webster MA USA
Posts: 241

Original Poster
Rep: Reputation: Disabled
Smile A simple solution (elemetary, even)

Just to settle my mind on the point, I entered this command in Konsole:
Code:
stat -c %A jericurl
The returned attributes were missing an x, which confused me a bit; one should expect that the script not run without the execution bit. I added it, to wit:
Code:
chmod 755 jericurl
ran it with a typical picture URL from Klipper, and it worked fine.
Sometimes it's the simplest thing that stumps you.

Carver
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash variable to Curl ethaniz3d Programming 18 08-11-2017 01:31 AM
Passing Curl result to a variable in a Bash script Entropy1024 Linux - Newbie 2 10-29-2015 04:50 PM
Find cannot interpret date from bash variable cosmbrth Programming 2 01-31-2014 09:23 AM
Bash scripting - find command with variable substitution and quoting bgeddy Programming 3 12-05-2008 08:00 AM
Bash variable problem: cURL -b parameter (string form e.g. "name=value;n2=v2") sithemac Other *NIX 3 07-09-2008 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration