wget postdata没有这样的文件或目录

时间:2016-04-26 12:19:54

标签: linux shell wget

"wget --user-agent=Mozilla/5.0 --save-cookies cookies.txt --post-data 'dir="$dir1"=&file="$file1"' --no-check-certificate http://test.com/mp3/file.php"

在命令行中一切正常但在shell脚本中它没有显示这样的文件或目录

  

wget --user-agent = Mozilla / 5.0 --save-cookies cookies.txt --post-data   'DIR = L011c2ljYW5fU2luZ2VyL1N1amF0aGEgSGl0cw ===&安培;文件= S2FhdHJ1IEthYXRydSAtIElzYWlBcnV2aS5OZXQubXAz'   --no-check-certificate http://test.com/mp3/file.php:没有这样的文件或目录

3 个答案:

答案 0 :(得分:0)

我不知道wget之前的双引号是格式错误("wget --user-a ...)还是实际上是你命令的一部分;无论哪种方式,删除它。另外,请尝试双引号。这在命令行和shell脚本中对我有用:

 wget --user-agent=Mozilla/5.0 --save-cookies cookies.txt --post-data 'dir="$dir1"=&file="$file1"' --no-check-certificate "http://test.com/mp3/file.php"

运行包含命令的脚本:

user@box:~$ sh wget_script.sh 
--2016-04-26 14:28:42--  http://test.com/mp3/file.php
Resolving test.com (test.com)... 69.172.200.235
Connecting to test.com (test.com)|69.172.200.235|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://www.test.com/ [following]
--2016-04-26 14:28:42--  https://www.test.com/
Resolving www.test.com (www.test.com)... 69.172.200.235
Connecting to www.test.com (www.test.com)|69.172.200.235|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘file.php’

    [ <=>                                                                                                          ] 1,557       --.-K/s   in 0s      

2016-04-26 14:28:42 (92.4 MB/s) - ‘file.php’ saved [1557]

user@box:~$ 

答案 1 :(得分:0)

也在脚本中定义你的变量。 (dir1 = and file =)

#!/bin/bash

dir1="bla"
file="blabl.bla"

wget --user-agent=Mozilla/5.0 --save-cookies cookies.txt --post-data 'dir="$dir1"=&file="$file1"' --no-check-certificate http://test.com/mp3/file.php

答案 2 :(得分:-1)

也许添加wget的路径会有所帮助:

which wget

将返回,例如/usr/bin/wget。尝试将该路径添加到命令行。