![Working Working](http://www.servermom.org/wp-content/uploads/2013/07/ion2.jpg)
Wget will only follow links, if there is no link to a file from the index page, then wget will not know about its existence, and hence not download it. It helps if all files are linked to in web pages or in directory indexes. Wget not converting links. Ask Question 6. Because of that, the work done by ‘-k’ will be performed at the end of all the downloads. Share| improve this answer. Edited May 23 '17 at 12:41. Make wget convert HTML links to relative after download if -k wasn't specified.
When wget is used my download fail. It seems that the server is not receiving a proper cookie header. I checked my puppet agent log and I saw this: Debug: Executing '/usr/bin/wget -O /tmp/jdk-7u80-linux-x64.tar.gz201-fy9sql -max-redirect=5 -header='Cookie: 'oraclelicense=accept-securebackup-cookie' If I run this manually in my shell, I got a wrong download. As you can see cookie header double quotes are wrong. I tried to change wget.rb from this (three double quotes on Cookie): params += optionalswitch(resource:cookie, '-header='Cookie: '%s') To this (two double quotes on Cookie): params += optionalswitch(resource:cookie, '-header='Cookie:%s') web server is still answering like it is receiving a wrong cookie but in this case If I run the command printed by the log in my shell manually then it works.
$ file /tmp/jdk-7u80-linux-x64.tar.gz /tmp/jdk-7u80-linux-x64.tar.gz: HTML document text $ head /tmp/jdk-7u80-linux-x64.tar.gz Unauthorized Request Do you have an working example? Cmd = 'wget ', ', '-O ', '/tmp/jdk-7u80-linux-x64.tar.gz2013-1m9avpd ', '-max-redirect=5 ', '-header= 'Cookie: oraclelicense=accept-securebackup-cookie ' ' This fails: Puppet::Util::Execution.execute(cmd), but this works Puppet::Util::Execution.execute(cmd.join(' ')). This is why wget(params) does not work, but my work around did. I'll put in a fix.
Puppet::Util::Execution is not happy with the ' escape double quote. In curl, the commands is something like.
I am using the os module to issue a wget request through python. It looks something like this: os.system('wget 'If I issue the wget request straight from terminal, it works, but I have two problems:. When I build this in sublime, it give me the error: sh: wget: command not found. When I enter this into a python shell command line it sends the request but comes back bad: 400 bad request I noticed that other people don't use the quotes around the url, but in terminal this is the only way it works.
I am using python 2.7.8 and running Yosemite. Your code should work if wget is on your PYTHONPATH.
But seriously, do not use wget in Python! Better use a Python-native function like urlopen: It's as simple as this: from urllib2 import urlopen response = urlopen('Now response contains the whole contents of the html page. You can also use readlines if you wanted to iterate over it line by line. To save the html file to disk use: download = open('index.html', 'w') download.write(response.read) download.close. I would guess one of two problems:. wget is not in your path. wget is not installed (I'm not trying to insult you) From a bash terminal type which wget.
That will tell you where wget is installed on your system. sri@localhost $ which wget /usr/bin/wget sri@localhost $ If which didn't locate wget then use find: sudo find / -name wget Once you know the path to wget, try adding the complete path to wget in your call to os.system: sri@localhost $ which wget /usr/bin/wget sri@localhost $ python Python 2.7.5 (default, Feb 19 2014, 13:47:40) GCC 4.8.2 20131212 (Red Hat 4.8.2-7) on linux2 Type 'help', 'copyright', 'credits' or 'license' for more information.
import os os.system('/usr/bin/wget 'www.asciitable.com') -2014-11-11 09:29:52- Resolving www.asciitable.com (www.asciitable.com). 192.185.246.35 Connecting to www.asciitable.com (www.asciitable.com) 192.185.246.35 :80. HTTP request sent, awaiting response. 200 OK Length: unspecified text/html Saving to: ‘index.html.1’ 6,853 -.-K/s in 0.006s 2014-11-11 09:29:53 (1.06 MB/s) - ‘index.html.1’ saved 6853 0.