【发布时间】:2016-01-28 22:43:02
【问题描述】:
我有一个执行 sh 脚本的 cronjob。该脚本还执行以下 python 脚本:
#!/usr/bin/python
print "Running python script"
LANG = "en_US.UTF-8"
import sys
py3 = sys.version_info[0] > 2
u = __import__('urllib.request' if py3 else 'urllib', fromlist=1)
exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read())
print "installing"
main(install_dir='/opt')
但是,main(install_dir='/opt') 不会在 cron 执行执行 Python 脚本的 sh 脚本时执行。如果我手动运行 sh 脚本,Python 脚本中的main(install_dir='/opt') 会执行,因为它应该执行。
为什么?
【问题讨论】:
-
我也试过
#!/usr/bin/env python,但无济于事。 -
我仍然收到此错误:
2014-03-07 00:00:06 URL:https://raw.github.com/kovidgoyal/calibre/master/setup/linux-installer.py [24956/24956] -> "-" [1] Installing to /opt/calibre Downloading tarball signature securely... Traceback (most recent call last): File "<string>", line 1, in <module> File "<string>", line 637, in main File "<string>", line 610, in download_and_extract File "<string>", line 321, in download_tarball File "<string>", line 259, in do_download File "<string>", line 206, in prints TypeError: encode() argument 1 must be string, not None
标签: python shell python-2.7 cron sh