Results 1 to 8 of 8
The following is a part of a script I've found on the Internet. My question is: When do you use the quotation marks around the URL? The manual page of ...
- 11-07-2007 #1Just Joined!
- Join Date
- Dec 2004
- Posts
- 2
wget
The following is a part of a script I've found on the Internet. My question is: When do you use the quotation marks around the URL? The manual page of wget does not say anything about using the marks.
wget -O $dns_tmp --http-user=$ZEuser \
--http-passwd=$ZEpasswd --no-check-certificate \
"https://dynamic.website.com/auth/dynamic.html?host=$domain"
- 11-07-2007 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
I would guess because the $domain is to be evaluated, it is a variable and not to be taken literally as a string for wget. With that said it should be evaluated anyway...so perhaps it's to contain certain escape characters that may interrupt the shell?
- 11-07-2007 #3
wget never sees the quotation marks. It's the shell that sees them and reacts to them. But it has nothing to do with "interrupting" the shell. The reason for the quotation marks is the question mark. Run this script to see why the author of the original script is showing good shell scripting habits.
Code:#!/bin/sh touch xxxaxxx touch xxxbxxx touch xxxcxxx echo xxx?xxx echo "xxx?xxx"
- 11-07-2007 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Ah yeah, I forgot that ? is a wildcard for any single character. Thanks for the clarification wje_lf
- 11-07-2007 #5Just Joined!
- Join Date
- Dec 2004
- Posts
- 2
Thank all of you for quick replies.
Although I understand the reason why you want to use " " around a string, but the question I posed concerns itself with wget and its arugument.
The question still remains: Does the URL need to be surrounded by " marks? In other words, when the URL is surrounded by the quotation marks, would it be recognized as an URL?wiget -options URL.
By the way, I got the same result with and without the quotations marks.Last edited by pinesol; 11-07-2007 at 05:04 PM. Reason: To clarify a point.
- 11-07-2007 #6
URL is parameter that you are passing to wget. It doesn't matter if you use double or single quotes or none unless you are passing variable using $ sign. Wildcards don't make any difference in static parameters.
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 11-07-2007 #7
Quoth the highly esteemed devils_casper:
I beg to differ. Consider the following shell script:It doesn't matter if you use double or single quotes or none unless you are passing variable using $ sign.
That should retrieve the results from searching for fred in google.Code:#!/bin/bash wget -O a1.html http://www.google.com/search?hl=en&q=fred&btnG=Google+Search
When you run it, you observe two things.
The second thing you observe is that the output in a1.html seems to give you not any search results, but the main google page.
The first thing you observe is that you don't seem to get a prompt back from the shell after completion. Actually, the returned prompt is there, usually on the line right after the one where you keyed in the script name. In other words, bash gave you the prompt back immediately, without waiting for the command to finish.
What happened?
Take a look at this line again:
Ooo. Doubleplusungood. See that question mark in there? To see what's going on, run this shell script:Code:wget -O a1.html http://www.google.com/search?hl=en&q=fred&btnG=Google+Search
The shell will act as though you had enteredCode:#!/bin/bash echo -O a1.html http://www.google.com/search?hl=en&q=fred&btnG=Google+Search
An unescaped, unprotected ampersand in a bash shell command will cause the command to be executed in the background, and you will get a prompt back immediately. I didn't know this before now, but apparently what comes after the ampersand is simply thrown away.Code:echo -O a1.html http://www.google.com/search?hl=en &
So it's a good habit to put at least double quotes around any URL on a bash command line (or, as devils_casper reminds us, single quotes if you don't need or want any $ in the URL to be bash-interpreted).
- 11-08-2007 #8
Thanx a lot for explanation wje_lf.
I appreciate it. Thanx again.
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First


Reply With Quote