python,subprocess(call或popen)在终端中工作,但在Gnome Schedule User Guide V2.2中不起作用

时间:2013-08-16 12:40:41

标签: python ubuntu subprocess wget scheduler

我试图从我的python(2.75)脚本调用wget:

cmd = ['wget', 'https://192.168.0.1/003/', '--tries=5', '--http-user=foo', '--http-passwd=bar', '--auth-no-challenge', '--no-check-certificate', '--output-document=temp/page.html']
proc = subprocess.Popen(cmd)
# same with subprocess.call(cmd)

它在IDE(eclipse)中工作正常,也在终端中,但是当我尝试从Gnome Schedule User Guide V2.2运行它时,我得到以下内容:

--2013-08-16 11:27:35--  https://192.168.0.1/003/
Connecting to 192.168.0.1:443... connected.
ERROR: cannot verify 192.168.0.1's certificate, issued by `blabla': Self-signed certificate encountered.
ERROR: no certificate subject alternative name matches requested host name `192.168.0.1'.
To connect to 192.168.0.1 insecurely, use `--no-check-certificate'.
--2013-08-16 11:27:37--  http://--tries=5/
Resolving --tries=5 (--tries=5)... failed: Name or service not known.
wget: unable to resolve host address `--tries=5'
--2013-08-16 11:27:37--  http://--http-user=foo/
Resolving --http-user=foo (--http-user=foo)... failed: Name or service not known.
wget: unable to resolve host address `--http-user=foo'
--2013-08-16 11:27:37--  http://--http-passwd=bar/
Resolving --http-passwd=bar (--http-passwd=bar)... failed: Name or service not known.
wget: unable to resolve host address `--http-passwd=bar'
--2013-08-16 11:27:37--  http://--auth-no-challenge/
Resolving --auth-no-challenge (--auth-no-challenge)... failed: Name or service not known.
wget: unable to resolve host address `--auth-no-challenge'
--2013-08-16 11:27:37--  http://--no-check-certificate/
Resolving --no-check-certificate (--no-check-certificate)... failed: Name or service not known.
wget: unable to resolve host address `--no-check-certificate'
--2013-08-16 11:27:37--  http://--output-document=temp/page.html
Resolving --output-document=temp (--output-document=temp)... failed: Name or service not known.
wget: unable to resolve host address `--output-document=temp'

...所以不是采取命令“wget arg1 arg2 arg3 ...”,它似乎试图运行: “wget arg1” “wget arg2” “wget arg3” ...

从调度程序运行时可能产生不同结果的任何线索?

我在调度程序中使用的命令是:     “python /home/python/Download/Download.py”

由于

1 个答案:

答案 0 :(得分:0)

我自己通过移动最后一个位置的第二个参数来解决它:

cmd = ['wget', '--tries=5', '--http-user=foo', '--http-passwd=bar', '--auth-no-challenge', '--no-check-certificate', '--output-document=temp/page.html', 'https://192.168.0.1/003/']

它现在有效,但我仍然想知道为什么在终端或IDE中它运行良好而不是从调度程序运行时...