我需要将文件下载到/ tmp/cron_test /.我的wget代码是
wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/
Run Code Online (Sandbox Code Playgroud)
那么是否有一些参数来指定目录?
Ric*_*dle 883
从手册页:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the
directory where all other files and sub-directories will be
saved to, i.e. the top of the retrieval tree. The default
is . (the current directory).
Run Code Online (Sandbox Code Playgroud)
所以你需要为你的命令添加-P /tmp/cron_test/(简短形式)或--directory-prefix=/tmp/cron_test/(长形式).另请注意,如果目录不存在,则会创建该目录.
小智 362
-O是指定要下载的文件的路径的选项.
wget <file.ext> -O /path/to/folder/file.ext
Run Code Online (Sandbox Code Playgroud)
-P是将在目录中下载文件的前缀
wget <file.ext> -P /path/to/folder
Run Code Online (Sandbox Code Playgroud)
小智 7
确保您所下载的内容的URL正确无误.首先,?无法解析和解析具有类似字符等的URL .这将混淆cmd行并接受未解析为源URL名称的任何字符作为要下载的文件名.
例如:
wget "sourceforge.net/projects/ebosse/files/latest/download?source=typ_redirect"
Run Code Online (Sandbox Code Playgroud)
将下载到名为的文件中?source=typ_redirect.
正如您所看到的,了解有关URL的一两件事有助于理解wget.
我从一个hirens磁盘启动,只有Linux 2.6.1作为资源(导入操作系统不可用).解决了将ISO下载到物理硬盘驱动器上的问题的正确语法是:
wget "(source url)" -O (directory where HD was mounted)/isofile.iso"
Run Code Online (Sandbox Code Playgroud)
可以通过查找wget下载到名为index.html(默认文件)的文件的哪个点来确定正确的URL ,并且具有您需要通过以下命令显示的文件的正确大小/其他属性:
wget "(source url)"
Run Code Online (Sandbox Code Playgroud)
一旦该URL和源文件正确并且正在下载index.html,您可以使用以下命令停止下载(ctrl+ z)并更改输出文件:
-O "<specified download directory>/filename.extension"
Run Code Online (Sandbox Code Playgroud)
在源网址之后.
在我的情况下,这导致下载ISO并将其存储为二进制文件isofile.iso,希望安装.
“-P”是正确的选项,请继续阅读以获取更多相关信息:
wget -nd -np -P /dest/dir --recursive http://url/dir1/dir2
为了方便起见,手册页中的相关片段:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is . (the current directory).
-nd
--no-directories
Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the
filenames will get extensions .n).
-np
--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.
Run Code Online (Sandbox Code Playgroud)